





from math import ceil





def 	lowerCAmelCase_					(			__a      ,       __a						)	->						Union[str, Any]:







  """simple docstring"""





  lowerCamelCase__: str         =list(range(0      ,       __a						)						)

  lowerCamelCase__: Dict         =[item for sublist in list(device_map.values()						) for item in sublist]

  # Duplicate check
  lowerCamelCase__: List[str]         =[]
  for i in device_map_blocks:
    if device_map_blocks.count(__a						) > 1 and i not in duplicate_blocks:
      duplicate_blocks.append(__a						)
    # Missing blocks
  lowerCamelCase__: Optional[Any]         =[i for i in blocks if i not in device_map_blocks]
  lowerCamelCase__: Union[str, Any]         =[i for i in device_map_blocks if i not in blocks]

  if len(__a						) != 0:
    raise ValueError(
        "Duplicate attention blocks specified in device_map. Attention blocks must be specified to one device."
        " These attention blocks were specified more than once: " + str(__a						)						)
  if len(__a						) != 0:
    raise ValueError(
        "There are attention blocks for this model that are not specified in the device_map. Add these attention "
        "blocks to a device on the device_map: " + str(__a						)						)
  if len(__a						) != 0:
    raise ValueError(
        "The device_map contains more attention blocks than this model has. Remove these from the device_map:"
        + str(__a						)						)






def 	lowerCAmelCase_					(			__a      ,       __a						)	->						Dict:







  """simple docstring"""





  lowerCamelCase__: List[Any]         =list(range(__a						)						)
  lowerCamelCase__: Tuple         =int(ceil(n_layers / len(__a						)						)						)
  lowerCamelCase__: Tuple         =[layers[i : i + n_blocks] for i in range(0      ,       __a      ,       __a						)]

  return dict(zip(__a      ,       __a						)						)









from typing import TYPE_CHECKING

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


__a   :							Optional[int]						= {"configuration_xlnet": ["XLNET_PRETRAINED_CONFIG_ARCHIVE_MAP", "XLNetConfig"]}

try:
  if not is_sentencepiece_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  __a   :							Tuple						= ["XLNetTokenizer"]

try:
  if not is_tokenizers_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  __a   :							List[str]						= ["XLNetTokenizerFast"]

try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  __a   :							Any						= [
      "XLNET_PRETRAINED_MODEL_ARCHIVE_LIST",
      "XLNetForMultipleChoice",
      "XLNetForQuestionAnswering",
      "XLNetForQuestionAnsweringSimple",
      "XLNetForSequenceClassification",
      "XLNetForTokenClassification",
      "XLNetLMHeadModel",
      "XLNetModel",
      "XLNetPreTrainedModel",
      "load_tf_weights_in_xlnet",
  ]

try:
  if not is_tf_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  __a   :							Dict						= [
      "TF_XLNET_PRETRAINED_MODEL_ARCHIVE_LIST",
      "TFXLNetForMultipleChoice",
      "TFXLNetForQuestionAnsweringSimple",
      "TFXLNetForSequenceClassification",
      "TFXLNetForTokenClassification",
      "TFXLNetLMHeadModel",
      "TFXLNetMainLayer",
      "TFXLNetModel",
      "TFXLNetPreTrainedModel",
  ]


if TYPE_CHECKING:
  from .configuration_xlnet import XLNET_PRETRAINED_CONFIG_ARCHIVE_MAP, XLNetConfig

  try:
    if not is_sentencepiece_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .tokenization_xlnet import XLNetTokenizer

  try:
    if not is_tokenizers_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .tokenization_xlnet_fast import XLNetTokenizerFast

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_xlnet import (
        XLNET_PRETRAINED_MODEL_ARCHIVE_LIST,
        XLNetForMultipleChoice,
        XLNetForQuestionAnswering,
        XLNetForQuestionAnsweringSimple,
        XLNetForSequenceClassification,
        XLNetForTokenClassification,
        XLNetLMHeadModel,
        XLNetModel,
        XLNetPreTrainedModel,
        load_tf_weights_in_xlnet,
    )

  try:
    if not is_tf_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_tf_xlnet import (
        TF_XLNET_PRETRAINED_MODEL_ARCHIVE_LIST,
        TFXLNetForMultipleChoice,
        TFXLNetForQuestionAnsweringSimple,
        TFXLNetForSequenceClassification,
        TFXLNetForTokenClassification,
        TFXLNetLMHeadModel,
        TFXLNetMainLayer,
        TFXLNetModel,
        TFXLNetPreTrainedModel,
    )

else:
  import sys

  __a   :							str						= _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)




