"""simple docstring"""


from typing import TYPE_CHECKING

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


UpperCAmelCase__     :   Optional[Any]  		=						{
    "configuration_funnel": ["FUNNEL_PRETRAINED_CONFIG_ARCHIVE_MAP", "FunnelConfig"],
    "convert_funnel_original_tf_checkpoint_to_pytorch": [],
    "tokenization_funnel": ["FunnelTokenizer"],
}

try:
    if not is_tokenizers_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    UpperCAmelCase__     :   Optional[Any]  		=						["FunnelTokenizerFast"]

try:
    if not is_torch_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    UpperCAmelCase__     :   Dict  		=						[
        "FUNNEL_PRETRAINED_MODEL_ARCHIVE_LIST",
        "FunnelBaseModel",
        "FunnelForMaskedLM",
        "FunnelForMultipleChoice",
        "FunnelForPreTraining",
        "FunnelForQuestionAnswering",
        "FunnelForSequenceClassification",
        "FunnelForTokenClassification",
        "FunnelModel",
        "FunnelPreTrainedModel",
        "load_tf_weights_in_funnel",
    ]

try:
    if not is_tf_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    UpperCAmelCase__     :   Tuple  		=						[
        "TF_FUNNEL_PRETRAINED_MODEL_ARCHIVE_LIST",
        "TFFunnelBaseModel",
        "TFFunnelForMaskedLM",
        "TFFunnelForMultipleChoice",
        "TFFunnelForPreTraining",
        "TFFunnelForQuestionAnswering",
        "TFFunnelForSequenceClassification",
        "TFFunnelForTokenClassification",
        "TFFunnelModel",
        "TFFunnelPreTrainedModel",
    ]


if TYPE_CHECKING:
    from .configuration_funnel import FUNNEL_PRETRAINED_CONFIG_ARCHIVE_MAP, FunnelConfig
    from .tokenization_funnel import FunnelTokenizer

    try:
        if not is_tokenizers_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .tokenization_funnel_fast import FunnelTokenizerFast

    try:
        if not is_torch_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_funnel import (
            FUNNEL_PRETRAINED_MODEL_ARCHIVE_LIST,
            FunnelBaseModel,
            FunnelForMaskedLM,
            FunnelForMultipleChoice,
            FunnelForPreTraining,
            FunnelForQuestionAnswering,
            FunnelForSequenceClassification,
            FunnelForTokenClassification,
            FunnelModel,
            FunnelPreTrainedModel,
            load_tf_weights_in_funnel,
        )

    try:
        if not is_tf_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_tf_funnel import (
            TF_FUNNEL_PRETRAINED_MODEL_ARCHIVE_LIST,
            TFFunnelBaseModel,
            TFFunnelForMaskedLM,
            TFFunnelForMultipleChoice,
            TFFunnelForPreTraining,
            TFFunnelForQuestionAnswering,
            TFFunnelForSequenceClassification,
            TFFunnelForTokenClassification,
            TFFunnelModel,
            TFFunnelPreTrainedModel,
        )

else:
    import sys

    UpperCAmelCase__     :   Optional[int]  		=						_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)

"""simple docstring"""


# Lint as: python3
import itertools
import os
import re


UpperCAmelCase__  		=						re.compile(r"""([A-Z]+)([A-Z][a-z])""")
UpperCAmelCase__  		=						re.compile(r"""([a-z\d])([A-Z])""")

UpperCAmelCase__  		=						re.compile(r"""(?<!_)_(?!_)""")
UpperCAmelCase__  		=						re.compile(r"""(_{2,})""")

UpperCAmelCase__  		=						r"""^\w+(\.\w+)*$"""

UpperCAmelCase__  		=						r"""<>:/\|?*"""






def     __UpperCAmelCase					(			lowercase		):







  """simple docstring"""
  _UpperCAmelCase						 =      _uppercase_uppercase_re.sub(R"""\1_\2"""   ,lowercase		)
  _UpperCAmelCase						 =      _lowercase_uppercase_re.sub(R"""\1_\2"""   ,lowercase		)
  return name.lower()






def     __UpperCAmelCase					(			lowercase		):







  """simple docstring"""
  _UpperCAmelCase						 =      _single_underscore_re.split(lowercase		)
  _UpperCAmelCase						 =      [_multiple_underscores_re.split(lowercase		) for n in name]
  return "".join(n.capitalize() for n in itertools.chain.from_iterable(lowercase		) if n != """"""		)






def     __UpperCAmelCase					(			lowercase		):







  """simple docstring"""
  if os.path.basename(lowercase		) != name:
    raise ValueError(f'''Should be a dataset name, not a path: {name}'''		)
  return camelcase_to_snakecase(lowercase		)






def     __UpperCAmelCase					(			lowercase   ,lowercase		):







  """simple docstring"""
  if os.path.basename(lowercase		) != name:
    raise ValueError(f'''Should be a dataset name, not a path: {name}'''		)
  if not re.match(_split_re   ,lowercase		):
    raise ValueError(f'''Split name should match \'{_split_re}\'\' but got \'{split}\'.'''		)
  return f'''{filename_prefix_for_name(lowercase		)}-{split}'''






def     __UpperCAmelCase					(			lowercase   ,lowercase   ,lowercase   ,lowercase=None		):







  """simple docstring"""
  _UpperCAmelCase						 =      filename_prefix_for_split(lowercase   ,lowercase		)
  if filetype_suffix:
    prefix += f'''.{filetype_suffix}'''
  _UpperCAmelCase						 =      os.path.join(lowercase   ,lowercase		)
  return f'''{filepath}*'''






def     __UpperCAmelCase					(			lowercase   ,lowercase   ,lowercase   ,lowercase=None   ,lowercase=None		):







  """simple docstring"""
  _UpperCAmelCase						 =      filename_prefix_for_split(lowercase   ,lowercase		)
  _UpperCAmelCase						 =      os.path.join(lowercase   ,lowercase		)

  if shard_lengths:
    _UpperCAmelCase						 =      len(lowercase		)
    _UpperCAmelCase						 =      [f'''{prefix}-{shard_id:05d}-of-{num_shards:05d}''' for shard_id in range(lowercase		)]
    if filetype_suffix:
      _UpperCAmelCase						 =      [filename + f'''.{filetype_suffix}''' for filename in filenames]
    return filenames
  else:
    _UpperCAmelCase						 =      prefix
    if filetype_suffix:
      filename += f'''.{filetype_suffix}'''
    return [filename]
