



'''simple docstring'''





from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_sentencepiece_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


lowercase_		       =  {
    'configuration_albert': ['ALBERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'AlbertConfig', 'AlbertOnnxConfig'],
}

try:
  if not is_sentencepiece_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  lowercase_		       =  ['AlbertTokenizer']

try:
  if not is_tokenizers_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  lowercase_		       =  ['AlbertTokenizerFast']

try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  lowercase_		       =  [
      'ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST',
      'AlbertForMaskedLM',
      'AlbertForMultipleChoice',
      'AlbertForPreTraining',
      'AlbertForQuestionAnswering',
      'AlbertForSequenceClassification',
      'AlbertForTokenClassification',
      'AlbertModel',
      'AlbertPreTrainedModel',
      'load_tf_weights_in_albert',
  ]

try:
  if not is_tf_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  lowercase_		       =  [
      'TF_ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST',
      'TFAlbertForMaskedLM',
      'TFAlbertForMultipleChoice',
      'TFAlbertForPreTraining',
      'TFAlbertForQuestionAnswering',
      'TFAlbertForSequenceClassification',
      'TFAlbertForTokenClassification',
      'TFAlbertMainLayer',
      'TFAlbertModel',
      'TFAlbertPreTrainedModel',
  ]

try:
  if not is_flax_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  lowercase_		       =  [
      'FlaxAlbertForMaskedLM',
      'FlaxAlbertForMultipleChoice',
      'FlaxAlbertForPreTraining',
      'FlaxAlbertForQuestionAnswering',
      'FlaxAlbertForSequenceClassification',
      'FlaxAlbertForTokenClassification',
      'FlaxAlbertModel',
      'FlaxAlbertPreTrainedModel',
  ]

if TYPE_CHECKING:
  from .configuration_albert import ALBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, AlbertConfig, AlbertOnnxConfig

  try:
    if not is_sentencepiece_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .tokenization_albert import AlbertTokenizer

  try:
    if not is_tokenizers_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .tokenization_albert_fast import AlbertTokenizerFast

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_albert import (
        ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
        AlbertForMaskedLM,
        AlbertForMultipleChoice,
        AlbertForPreTraining,
        AlbertForQuestionAnswering,
        AlbertForSequenceClassification,
        AlbertForTokenClassification,
        AlbertModel,
        AlbertPreTrainedModel,
        load_tf_weights_in_albert,
    )

  try:
    if not is_tf_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_tf_albert import (
        TF_ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
        TFAlbertForMaskedLM,
        TFAlbertForMultipleChoice,
        TFAlbertForPreTraining,
        TFAlbertForQuestionAnswering,
        TFAlbertForSequenceClassification,
        TFAlbertForTokenClassification,
        TFAlbertMainLayer,
        TFAlbertModel,
        TFAlbertPreTrainedModel,
    )

  try:
    if not is_flax_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_flax_albert import (
        FlaxAlbertForMaskedLM,
        FlaxAlbertForMultipleChoice,
        FlaxAlbertForPreTraining,
        FlaxAlbertForQuestionAnswering,
        FlaxAlbertForSequenceClassification,
        FlaxAlbertForTokenClassification,
        FlaxAlbertModel,
        FlaxAlbertPreTrainedModel,
    )
else:
  import sys

  lowercase_		       =  _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)







import importlib.metadata
import operator
import re
import sys
from typing import Optional

from packaging import version


__lowerCAmelCase	: Union[str, Any]  				={
    '<': operator.lt,
    '<=': operator.le,
    '==': operator.eq,
    '!=': operator.ne,
    '>=': operator.ge,
    '>': operator.gt,
}


def        _UpperCamelCase							(      lowercase__    ,       lowercase__    ,       lowercase__    ,       lowercase__    ,       lowercase__    ,       lowercase__      ):
						if got_ver is None or want_ver is None:
												raise ValueError(
												    F'''Unable to compare versions for {requirement}: need={want_ver} found={got_ver}. This is unusual. Consider'''
												    F''' reinstalling {pkg}.'''      )
						if not ops[op](version.parse(lowercase__      )    ,       version.parse(lowercase__      )      ):
												raise ImportError(
												    F'''{requirement} is required for a normal functioning of this module, but found {pkg}=={got_ver}.{hint}'''      )


def        _UpperCamelCase							(      lowercase__    ,       lowercase__ = None      ):
						__SCREAMING_SNAKE_CASE						:     Union[str, Any]					=		F'''\n{hint}''' if hint is not None else ''''''

						# non-versioned check
						if re.match(R'''^[\w_\-\d]+$'''    ,       lowercase__      ):
												__SCREAMING_SNAKE_CASE			,			__SCREAMING_SNAKE_CASE			,			__SCREAMING_SNAKE_CASE						:     str					=		requirement, None, None
						else:
												__SCREAMING_SNAKE_CASE						:     List[Any]					=		re.findall(R'''^([^!=<>\s]+)([\s!=<>]{1,2}.+)'''    ,       lowercase__      )
												if not match:
																		raise ValueError(
																		    '''requirement needs to be in the pip package format, .e.g., package_a==1.23, or package_b>=1.23, but'''
																		    F''' got {requirement}'''      )
												__SCREAMING_SNAKE_CASE			,			__SCREAMING_SNAKE_CASE						:     Tuple					=		match[0]
												__SCREAMING_SNAKE_CASE						:     Optional[int]					=		want_full.split(''','''      )  # there could be multiple requirements
												__SCREAMING_SNAKE_CASE						:     Optional[Any]					=		{}
												for w in want_range:
																		__SCREAMING_SNAKE_CASE						:     Any					=		re.findall(R'''^([\s!=<>]{1,2})(.+)'''    ,       lowercase__      )
																		if not match:
																								raise ValueError(
																								    '''requirement needs to be in the pip package format, .e.g., package_a==1.23, or package_b>=1.23,'''
																								    F''' but got {requirement}'''      )
																		__SCREAMING_SNAKE_CASE			,			__SCREAMING_SNAKE_CASE						:     Tuple					=		match[0]
																		__SCREAMING_SNAKE_CASE						:     List[Any]					=		want_ver
																		if op not in ops:
																								raise ValueError(F'''{requirement}: need one of {list(ops.keys()      )}, but got {op}'''      )

    # special case
						if pkg == "python":
												__SCREAMING_SNAKE_CASE						:     Optional[Any]					=		'''.'''.join([str(lowercase__      ) for x in sys.version_info[:3]]      )
												for op, want_ver in wanted.items():
																		_compare_versions(lowercase__    ,       lowercase__    ,       lowercase__    ,       lowercase__    ,       lowercase__    ,       lowercase__      )
												return

						# check if any version is installed
						try:
												__SCREAMING_SNAKE_CASE						:     Optional[int]					=		importlib.metadata.version(lowercase__      )
						except importlib.metadata.PackageNotFoundError:
												raise importlib.metadata.PackageNotFoundError(
												    F'''The \'{requirement}\' distribution was not found and is required by this application. {hint}'''      )

						# check that the right version is installed if version number or a range was provided
						if want_ver is not None:
												for op, want_ver in wanted.items():
																		_compare_versions(lowercase__    ,       lowercase__    ,       lowercase__    ,       lowercase__    ,       lowercase__    ,       lowercase__      )


def        _UpperCamelCase							(      lowercase__      ):
						__SCREAMING_SNAKE_CASE						:     Union[str, Any]					=		'''Try: pip install transformers -U or pip install -e \'.[dev]\' if you\'re working with git main'''
						return require_version(lowercase__    ,       lowercase__      )
