





'''simple docstring'''

import tempfile
import unittest

from transformers import TaConfig, is_torch_available
from transformers.testing_utils import (
    require_sentencepiece,
    require_tokenizers,
    require_torch,
    slow,
    torch_device,
)

from ...generation.test_utils import GenerationTesterMixin
from ...test_modeling_common import ModelTesterMixin, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
    import torch

    from transformers import AutoTokenizer, UMTaForConditionalGeneration, UMTaForQuestionAnswering, UMTaModel







class __a			:





   def __init__(       self					:      List[str]					,lowerCamelCase					:      Any					,lowerCamelCase					:      Tuple=99					,lowerCamelCase					:      Any=13					,lowerCamelCase					:      List[str]=7					,lowerCamelCase					:      Optional[Any]=9					,lowerCamelCase					:      Dict=True					,lowerCamelCase					:      str=True					,lowerCamelCase					:      Dict=False					,lowerCamelCase					:      str=32					,lowerCamelCase					:      List[str]=5					,lowerCamelCase					:      Tuple=4					,lowerCamelCase					:      Optional[Any]=37					,lowerCamelCase					:      int=8					,lowerCamelCase					:      Optional[int]=0.1					,lowerCamelCase					:      str=0.002					,lowerCamelCase					:      Any=1					,lowerCamelCase					:      List[Any]=0					,lowerCamelCase					:      Tuple=0					,lowerCamelCase					:      Tuple=None					,lowerCamelCase					:      Any=None					,):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE   				=							parent
      __SCREAMING_SNAKE_CASE   				=							batch_size
      __SCREAMING_SNAKE_CASE   				=							encoder_seq_length
      __SCREAMING_SNAKE_CASE   				=							decoder_seq_length
      # For common tests
      __SCREAMING_SNAKE_CASE   				=							self.decoder_seq_length
      __SCREAMING_SNAKE_CASE   				=							is_training
      __SCREAMING_SNAKE_CASE   				=							use_attention_mask
      __SCREAMING_SNAKE_CASE   				=							use_labels
      __SCREAMING_SNAKE_CASE   				=							vocab_size
      __SCREAMING_SNAKE_CASE   				=							hidden_size
      __SCREAMING_SNAKE_CASE   				=							num_hidden_layers
      __SCREAMING_SNAKE_CASE   				=							num_attention_heads
      __SCREAMING_SNAKE_CASE   				=							d_ff
      __SCREAMING_SNAKE_CASE   				=							relative_attention_num_buckets
      __SCREAMING_SNAKE_CASE   				=							dropout_rate
      __SCREAMING_SNAKE_CASE   				=							initializer_factor
      __SCREAMING_SNAKE_CASE   				=							eos_token_id
      __SCREAMING_SNAKE_CASE   				=							pad_token_id
      __SCREAMING_SNAKE_CASE   				=							decoder_start_token_id
      __SCREAMING_SNAKE_CASE   				=							None
      __SCREAMING_SNAKE_CASE   				=							decoder_layers





   def   UpperCAmelCase__  (       self					:      Any     ):

      '''simple docstring'''

      return TaConfig.from_pretrained("""google/umt5-base"""     )





   def   UpperCAmelCase__  (       self					:      Optional[int]					,lowerCamelCase					:      Dict					,lowerCamelCase					:      Any					,lowerCamelCase					:      Optional[Any]					,lowerCamelCase					:      Tuple=None					,lowerCamelCase					:      Union[str, Any]=None					,lowerCamelCase					:      Dict=None					,lowerCamelCase					:      int=None					,lowerCamelCase					:      str=None					,):

      '''simple docstring'''

      if attention_mask is None:
         __SCREAMING_SNAKE_CASE   				=							input_ids.ne(config.pad_token_id     )
      if decoder_attention_mask is None:
         __SCREAMING_SNAKE_CASE   				=							decoder_input_ids.ne(config.pad_token_id     )
      if head_mask is None:
         __SCREAMING_SNAKE_CASE   				=							torch.ones(config.num_hidden_layers					,config.num_attention_heads					,device=lowerCamelCase     )
      if decoder_head_mask is None:
         __SCREAMING_SNAKE_CASE   				=							torch.ones(config.num_decoder_layers					,config.num_attention_heads					,device=lowerCamelCase     )
      if cross_attn_head_mask is None:
         __SCREAMING_SNAKE_CASE   				=							torch.ones(
             config.num_decoder_layers					,config.num_attention_heads					,device=lowerCamelCase     )
      return {
          "input_ids": input_ids,
          "decoder_input_ids": decoder_input_ids,
          "attention_mask": attention_mask,
          "decoder_attention_mask": decoder_attention_mask,
          "head_mask": head_mask,
          "decoder_head_mask": decoder_head_mask,
          "cross_attn_head_mask": cross_attn_head_mask,
      }





   def   UpperCAmelCase__  (       self					:      Any     ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE   				=							ids_tensor([self.batch_size, self.encoder_seq_length]					,self.vocab_size     )
      __SCREAMING_SNAKE_CASE   				=							ids_tensor([self.batch_size, self.decoder_seq_length]					,self.vocab_size     )

      # we need to clamp the input ids here to avoid having pad token in between
      # this is because for NllbMoe the position_ids are prepared such that
      # all pad tokens have pos id = 2 and rest are between 2..seq_length
      # and the seq_length here is seq_length - num_pad_tokens
      # but when using past, there is no way of knowing if the past input ids had
      # pad tokens in them, which results in incorrect seq_lenth and which in turn results in
      # position_ids being off by num_pad_tokens in past input
      __SCREAMING_SNAKE_CASE   				=							input_ids.clamp(self.pad_token_id + 1     )
      __SCREAMING_SNAKE_CASE   				=							decoder_input_ids.clamp(self.pad_token_id + 1     )

      __SCREAMING_SNAKE_CASE   				=							self.get_config()
      __SCREAMING_SNAKE_CASE   				=							config.num_attention_heads
      __SCREAMING_SNAKE_CASE   				=							self.prepare_inputs_dict(lowerCamelCase					,lowerCamelCase					,lowerCamelCase     )
      return config, input_dict





   def   UpperCAmelCase__  (       self					:      str     ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE				,  __SCREAMING_SNAKE_CASE   				=							self.prepare_config_and_inputs()
      return config, inputs_dict





   def   UpperCAmelCase__  (       self					:      Dict     ):

      '''simple docstring'''

      return TaConfig(
          vocab_size=166					,d_model=self.hidden_size					,d_ff=self.d_ff					,d_kv=self.hidden_size // self.num_attention_heads					,num_layers=self.num_hidden_layers					,num_decoder_layers=self.decoder_layers					,num_heads=self.num_attention_heads					,relative_attention_num_buckets=self.relative_attention_num_buckets					,dropout_rate=self.dropout_rate					,initializer_factor=self.initializer_factor					,eos_token_id=self.eos_token_id					,bos_token_id=self.pad_token_id					,pad_token_id=self.pad_token_id					,decoder_start_token_id=self.decoder_start_token_id					,)





   def   UpperCAmelCase__  (       self					:      Optional[int]     ):

      '''simple docstring'''

      return TaConfig(
          vocab_size=self.vocab_size					,d_model=self.hidden_size					,d_ff=self.d_ff					,d_kv=self.hidden_size // self.num_attention_heads					,num_layers=self.num_hidden_layers					,num_decoder_layers=self.decoder_layers					,num_heads=self.num_attention_heads					,relative_attention_num_buckets=self.relative_attention_num_buckets					,dropout_rate=self.dropout_rate					,initializer_factor=self.initializer_factor					,eos_token_id=self.eos_token_id					,bos_token_id=self.pad_token_id					,pad_token_id=self.pad_token_id					,decoder_start_token_id=self.decoder_start_token_id					,)





   def   UpperCAmelCase__  (       self					:      Tuple					,lowerCamelCase					:      str					,lowerCamelCase					:      Dict					,lowerCamelCase					:      Tuple					,lowerCamelCase					:      Any					,lowerCamelCase					:      Optional[int]					,lowerCamelCase					:      Union[str, Any]					,):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE   				=							UMTaModel(config=lowerCamelCase     )
      model.to(lowerCamelCase     )
      model.eval()
      __SCREAMING_SNAKE_CASE   				=							model(
          input_ids=lowerCamelCase					,decoder_input_ids=lowerCamelCase					,attention_mask=lowerCamelCase					,decoder_attention_mask=lowerCamelCase					,)
      __SCREAMING_SNAKE_CASE   				=							model(input_ids=lowerCamelCase					,decoder_input_ids=lowerCamelCase     )
      __SCREAMING_SNAKE_CASE   				=							result.last_hidden_state
      __SCREAMING_SNAKE_CASE   				=							result.past_key_values
      __SCREAMING_SNAKE_CASE   				=							result.encoder_last_hidden_state

      self.parent.assertEqual(encoder_output.size()					,(self.batch_size, self.encoder_seq_length, self.hidden_size)     )
      self.parent.assertEqual(decoder_output.size()					,(self.batch_size, self.decoder_seq_length, self.hidden_size)     )
      # There should be `num_layers` key value embeddings stored in decoder_past
      self.parent.assertEqual(len(lowerCamelCase     )					,config.num_layers     )
      # There should be a self attn key, a self attn value, a cross attn key and a cross attn value stored in each decoder_past tuple
      self.parent.assertEqual(len(decoder_past[0]     )					,4     )





   def   UpperCAmelCase__  (       self					:      Dict					,lowerCamelCase					:      str					,lowerCamelCase					:      List[str]					,lowerCamelCase					:      Optional[int]					,lowerCamelCase					:      Optional[int]					,lowerCamelCase					:      int					,lowerCamelCase					:      Optional[int]					,):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE   				=							UMTaModel(config=lowerCamelCase     ).get_decoder().to(lowerCamelCase     ).eval()
      # first forward pass
      __SCREAMING_SNAKE_CASE   				=							model(lowerCamelCase					,use_cache=lowerCamelCase     )
      __SCREAMING_SNAKE_CASE   				=							model(lowerCamelCase     )
      __SCREAMING_SNAKE_CASE   				=							model(lowerCamelCase					,use_cache=lowerCamelCase     )

      self.parent.assertTrue(len(lowerCamelCase     ) == len(lowerCamelCase     )     )
      self.parent.assertTrue(len(lowerCamelCase     ) == len(lowerCamelCase     ) + 1     )

      __SCREAMING_SNAKE_CASE				,  __SCREAMING_SNAKE_CASE   				=							outputs.to_tuple()

      # create hypothetical next token and extent to next_input_ids
      __SCREAMING_SNAKE_CASE   				=							ids_tensor((self.batch_size, 1)					,config.vocab_size     )

      # append to next input_ids and
      __SCREAMING_SNAKE_CASE   				=							torch.cat([input_ids, next_tokens]					,dim=-1     )

      __SCREAMING_SNAKE_CASE   				=							model(lowerCamelCase     )["""last_hidden_state"""]
      __SCREAMING_SNAKE_CASE   				=							model(lowerCamelCase					,past_key_values=lowerCamelCase     )["""last_hidden_state"""]

      # select random slice
      __SCREAMING_SNAKE_CASE   				=							ids_tensor((1,)					,output_from_past.shape[-1]     ).item()
      __SCREAMING_SNAKE_CASE   				=							output_from_no_past[:, -1, random_slice_idx].detach()
      __SCREAMING_SNAKE_CASE   				=							output_from_past[:, 0, random_slice_idx].detach()

      # test that outputs are equal for slice
      self.parent.assertTrue(torch.allclose(lowerCamelCase					,lowerCamelCase					,atol=1E-3     )     )





   def   UpperCAmelCase__  (       self					:      Dict					,lowerCamelCase					:      Optional[Any]					,lowerCamelCase					:      Union[str, Any]					,):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE   				=							UMTaModel(config=lowerCamelCase     ).to(lowerCamelCase     ).half().eval()
      __SCREAMING_SNAKE_CASE   				=							model(**lowerCamelCase     )["""last_hidden_state"""]
      self.parent.assertFalse(torch.isnan(lowerCamelCase     ).any().item()     )







@require_torch
class __a			( _snake_case, _snake_case, _snake_case, unittest.TestCase      ):
   __UpperCamelCase :			Union[str, Any]						   =						(
       (UMTaModel, UMTaForConditionalGeneration, UMTaForQuestionAnswering) if is_torch_available() else ()
   )
   __UpperCamelCase :			Dict						   =						(UMTaForConditionalGeneration,) if is_torch_available() else ()
   __UpperCamelCase :			Dict						   =						(
       {
           'conversational': UMTaForConditionalGeneration,
           'feature-extraction': UMTaModel,
           'summarization': UMTaForConditionalGeneration,
           'text2text-generation': UMTaForConditionalGeneration,
           'translation': UMTaForConditionalGeneration,
           'question-answering': UMTaForQuestionAnswering,
       }
       if is_torch_available()
       else {}
   )
   __UpperCamelCase :			List[Any]						   =						True
   __UpperCamelCase :			str						   =						False
   __UpperCamelCase :			Dict						   =						False
   __UpperCamelCase :			Optional[Any]						   =						True
   __UpperCamelCase :			Any						   =						True
   # The small UMT5 model needs higher percentages for CPU/MP tests
   __UpperCamelCase :			Any						   =						[0.8, 0.9]





   def   UpperCAmelCase__  (       self					:      Dict     ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE   				=							UMTaModelTester(self     )





   @unittest.skip("""Test has a segmentation fault on torch 1.8.0"""     )
   def   UpperCAmelCase__  (       self					:      Tuple     ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE   				=							self.model_tester.prepare_config_and_inputs()
      __SCREAMING_SNAKE_CASE   				=							UMTaModel(config_and_inputs[0]     ).to(lowerCamelCase     )
      with tempfile.TemporaryDirectory() as tmpdirname:
         torch.onnx.export(
             lowerCamelCase					,(config_and_inputs[1], config_and_inputs[3], config_and_inputs[2])					,f"""{tmpdirname}/t5_test.onnx"""					,export_params=lowerCamelCase					,opset_version=9					,input_names=["""input_ids""", """decoder_input_ids"""]					,)





   @unittest.skipIf(torch_device == """cpu"""					,"""Cant do half precision"""     )
   def   UpperCAmelCase__  (       self					:      Tuple     ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE   				=							self.model_tester.prepare_config_and_inputs()
      self.model_tester.create_and_check_model_fpaa_forward(*lowerCamelCase     )





   def   UpperCAmelCase__  (       self					:      Optional[Any]     ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE   				=							["""encoder_attentions""", """decoder_attentions""", """cross_attentions"""]
      __SCREAMING_SNAKE_CASE   				=							self.model_tester.prepare_config_and_inputs()
      __SCREAMING_SNAKE_CASE   				=							config_and_inputs[0]
      __SCREAMING_SNAKE_CASE   				=							UMTaForConditionalGeneration(lowerCamelCase     ).eval()
      model.to(lowerCamelCase     )

      __SCREAMING_SNAKE_CASE   				=							{
          """head_mask""": torch.zeros(config.num_layers					,config.num_heads					,device=lowerCamelCase     ),
          """decoder_head_mask""": torch.zeros(config.num_decoder_layers					,config.num_heads					,device=lowerCamelCase     ),
          """cross_attn_head_mask""": torch.zeros(config.num_decoder_layers					,config.num_heads					,device=lowerCamelCase     ),
      }

      for attn_name, (name, mask) in zip(lowerCamelCase					,head_masking.items()     ):
         __SCREAMING_SNAKE_CASE   				=							{name: mask}
         # Explicitly pass decoder_head_mask as it is required from T5 model when head_mask specified
         if name == "head_mask":
            __SCREAMING_SNAKE_CASE   				=							torch.ones(
                config.num_decoder_layers					,config.num_heads					,device=lowerCamelCase     )

         __SCREAMING_SNAKE_CASE   				=							model.generate(
             config_and_inputs[1]["""input_ids"""]					,num_beams=1					,max_length=3					,output_attentions=lowerCamelCase					,return_dict_in_generate=lowerCamelCase					,**lowerCamelCase					,)
         # We check the state of decoder_attentions and cross_attentions just from the last step
         __SCREAMING_SNAKE_CASE   				=							out[attn_name] if attn_name == attention_names[0] else out[attn_name][-1]
         self.assertEqual(sum([w.sum().item() for w in attn_weights]     )					,0.0     )





   @unittest.skip("""Does not work on the tiny model as we keep hitting edge cases."""     )
   def   UpperCAmelCase__  (       self					:      Optional[Any]     ):

      '''simple docstring'''

      pass







@require_torch
@require_sentencepiece
@require_tokenizers
class __a			( unittest.TestCase      ):





   @slow
   @unittest.skip(
       """Unless we stop stripping left and right by default for all special tokens, the expected ids obtained here will not match the original ones. Wait for https://github.com/huggingface/transformers/pull/23909 to be merged"""     )
   def   UpperCAmelCase__  (       self					:      str     ):

      '''simple docstring'''

      __SCREAMING_SNAKE_CASE   				=							UMTaForConditionalGeneration.from_pretrained("""google/umt5-small"""					,return_dict=lowerCamelCase     ).to(lowerCamelCase     )
      __SCREAMING_SNAKE_CASE   				=							AutoTokenizer.from_pretrained("""google/umt5-small"""					,use_fast=lowerCamelCase					,legacy=lowerCamelCase     )
      __SCREAMING_SNAKE_CASE   				=							[
          """Bonjour monsieur <extra_id_0> bien <extra_id_1>.""",
          """No se como puedo <extra_id_0>.""",
          """This is the reason why we <extra_id_0> them.""",
          """The <extra_id_0> walks in <extra_id_1>, seats""",
          """A <extra_id_0> walks into a bar and orders a <extra_id_1> with <extra_id_2> pinch of <extra_id_3>.""",
      ]
      __SCREAMING_SNAKE_CASE   				=							tokenizer(lowerCamelCase					,return_tensors="""pt"""					,padding=lowerCamelCase     ).input_ids
      # fmt: off
      __SCREAMING_SNAKE_CASE   				=							torch.tensor(
          [
              [ 3_8530, 21_0703, 25_6299, 1410, 25_6298, 274, 1, 0,0, 0, 0, 0, 0, 0, 0, 0,0, 0],
              [   826, 321, 671, 2_5922, 25_6299, 274, 1, 0,0, 0, 0, 0, 0, 0, 0, 0,0, 0],
              [  1460, 339, 312, 1_9014, 1_0620, 758, 25_6299, 2355,274, 1, 0, 0, 0, 0, 0, 0,0, 0],
              [   517, 25_6299, 1_4869, 281, 301, 25_6298, 275, 11_9983,1, 0, 0, 0, 0, 0, 0, 0,0, 0],
              [   320, 25_6299, 1_4869, 281, 2234, 289, 2275, 333,6_1391, 289, 25_6298, 543, 25_6297, 16_8714, 329, 25_6296,274, 1],
          ]     )
      # fmt: on
      torch.testing.assert_allclose(lowerCamelCase					,lowerCamelCase     )

      __SCREAMING_SNAKE_CASE   				=							model.generate(input_ids.to(lowerCamelCase     )     )
      __SCREAMING_SNAKE_CASE   				=							[
          """<pad><extra_id_0> et<extra_id_1> [eod] <extra_id_2><extra_id_55>.. [eod] 💐 💐 💐 💐 💐 💐 💐 💐 💐 💐 💐 <extra_id_56>ajšietosto<extra_id_56>lleux<extra_id_19><extra_id_6>ajšie</s>""",
          """<pad><extra_id_0>.<extra_id_1>.,<0x0A>...spech <0x0A><extra_id_20> <extra_id_21></s><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad>""",
          """<pad><extra_id_0> are not going to be a part of the world. We are not going to be a part of<extra_id_1> and<extra_id_2><0x0A><extra_id_48>.<extra_id_48></s><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad>""",
          """<pad><extra_id_0> door<extra_id_1>, the door<extra_id_2> 피해[/</s><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad>""",
          """<pad><extra_id_0>nyone who<extra_id_1> drink<extra_id_2> a<extra_id_3> alcohol<extra_id_4> A<extra_id_5> A. This<extra_id_6> I<extra_id_7><extra_id_52><extra_id_53></s><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad><pad>""",
      ]
      __SCREAMING_SNAKE_CASE   				=							tokenizer.batch_decode(lowerCamelCase     )
      self.assertEqual(lowerCamelCase					,lowerCamelCase     )








# Copyright 2021 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from packaging import version

from .. import __version__
from .constants import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD, IMAGENET_STANDARD_MEAN, IMAGENET_STANDARD_STD
from .doc import (
    add_code_sample_docstrings,
    add_end_docstrings,
    add_start_docstrings,
    add_start_docstrings_to_model_forward,
    copy_func,
    replace_return_docstrings,
)
from .generic import (
    ContextManagers,
    ExplicitEnum,
    ModelOutput,
    PaddingStrategy,
    TensorType,
    add_model_info_to_auto_map,
    cached_property,
    can_return_loss,
    expand_dims,
    find_labels,
    flatten_dict,
    infer_framework,
    is_jax_tensor,
    is_numpy_array,
    is_tensor,
    is_tf_symbolic_tensor,
    is_tf_tensor,
    is_torch_device,
    is_torch_dtype,
    is_torch_tensor,
    reshape,
    squeeze,
    strtobool,
    tensor_size,
    to_numpy,
    to_py_obj,
    transpose,
    working_or_temp_dir,
)
from .hub import (
    CLOUDFRONT_DISTRIB_PREFIX,
    DISABLE_TELEMETRY,
    HF_MODULES_CACHE,
    HUGGINGFACE_CO_PREFIX,
    HUGGINGFACE_CO_RESOLVE_ENDPOINT,
    PYTORCH_PRETRAINED_BERT_CACHE,
    PYTORCH_TRANSFORMERS_CACHE,
    S3_BUCKET_PREFIX,
    TRANSFORMERS_CACHE,
    TRANSFORMERS_DYNAMIC_MODULE_NAME,
    EntryNotFoundError,
    PushToHubMixin,
    RepositoryNotFoundError,
    RevisionNotFoundError,
    cached_file,
    default_cache_path,
    define_sagemaker_information,
    download_url,
    extract_commit_hash,
    get_cached_models,
    get_file_from_repo,
    get_full_repo_name,
    has_file,
    http_user_agent,
    is_offline_mode,
    is_remote_url,
    move_cache,
    send_example_telemetry,
    try_to_load_from_cache,
)
from .import_utils import (
    ENV_VARS_TRUE_AND_AUTO_VALUES,
    ENV_VARS_TRUE_VALUES,
    TORCH_FX_REQUIRED_VERSION,
    USE_JAX,
    USE_TF,
    USE_TORCH,
    DummyObject,
    OptionalDependencyNotAvailable,
    _LazyModule,
    ccl_version,
    direct_transformers_import,
    get_torch_version,
    is_accelerate_available,
    is_apex_available,
    is_bitsandbytes_available,
    is_bsa_available,
    is_coloredlogs_available,
    is_cython_available,
    is_datasets_available,
    is_decord_available,
    is_detectrona_available,
    is_faiss_available,
    is_flax_available,
    is_ftfy_available,
    is_in_notebook,
    is_ipex_available,
    is_jieba_available,
    is_jumanpp_available,
    is_kenlm_available,
    is_keras_nlp_available,
    is_librosa_available,
    is_natten_available,
    is_ninja_available,
    is_onnx_available,
    is_openai_available,
    is_optimum_available,
    is_pandas_available,
    is_peft_available,
    is_phonemizer_available,
    is_protobuf_available,
    is_psutil_available,
    is_pyanvml_available,
    is_pyctcdecode_available,
    is_pytesseract_available,
    is_pytest_available,
    is_pytorch_quantization_available,
    is_rjieba_available,
    is_sacremoses_available,
    is_safetensors_available,
    is_sagemaker_dp_enabled,
    is_sagemaker_mp_enabled,
    is_scipy_available,
    is_sentencepiece_available,
    is_seqio_available,
    is_sklearn_available,
    is_soundfile_availble,
    is_spacy_available,
    is_speech_available,
    is_sudachi_available,
    is_tensorflow_probability_available,
    is_tensorflow_text_available,
    is_tfaonnx_available,
    is_tf_available,
    is_timm_available,
    is_tokenizers_available,
    is_torch_available,
    is_torch_bfaa_available,
    is_torch_bfaa_cpu_available,
    is_torch_bfaa_gpu_available,
    is_torch_compile_available,
    is_torch_cuda_available,
    is_torch_fx_available,
    is_torch_fx_proxy,
    is_torch_mps_available,
    is_torch_neuroncore_available,
    is_torch_tensorrt_fx_available,
    is_torch_tfaa_available,
    is_torch_tpu_available,
    is_torchaudio_available,
    is_torchdistx_available,
    is_torchdynamo_available,
    is_torchvision_available,
    is_training_run_on_sagemaker,
    is_vision_available,
    requires_backends,
    torch_only_method,
)


lowercase_   							=  'pytorch_model.bin'
lowercase_   							=  'pytorch_model.bin.index.json'
lowercase_   							=  'adapter_config.json'
lowercase_   							=  'adapter_model.bin'
lowercase_   							=  'adapter_model.safetensors'
lowercase_   							=  'tf_model.h5'
lowercase_   							=  'tf_model.h5.index.json'
lowercase_   							=  'model.ckpt'
lowercase_   							=  'flax_model.msgpack'
lowercase_   							=  'flax_model.msgpack.index.json'
lowercase_   							=  'model.safetensors'
lowercase_   							=  'model.safetensors.index.json'
lowercase_   							=  'config.json'
lowercase_   							=  'preprocessor_config.json'
lowercase_   							=  FEATURE_EXTRACTOR_NAME
lowercase_   							=  'generation_config.json'
lowercase_   							=  'modelcard.json'

lowercase_   							=  '▁'
lowercase_   							=  SENTENCEPIECE_UNDERLINE  # Kept for backward compatibility

lowercase_   							=  [
    [[0, 1, 0, 1], [1, 0, 0, 1]]
] * 2  # Needs to have 0s and 1s only since XLM uses it for langs too.
lowercase_   							=  [[7, 6, 0, 0, 1], [1, 2, 3, 0, 0], [0, 0, 0, 4, 5]]
lowercase_   							=  [[1, 1, 1, 1, 1], [1, 1, 1, 0, 0], [0, 0, 0, 1, 1]]
def 	a (     A__      :  List[str]	)       -> str:





      """simple docstring"""



      if version.parse(A__	) < version.parse(A__	):
            if "dev" in min_version:
                  _lowercase      			=(
                      'This example requires a source install from HuggingFace Transformers (see '
                      '`https://huggingface.co/docs/transformers/installation#install-from-source`),'
                  )
            else:
                  _lowercase      			=F'''This example requires a minimum version of {min_version},'''
            error_message += F''' but the version found is {__version__}.\n'''
            raise ImportError(
                error_message
                + 'Check out https://github.com/huggingface/transformers/tree/main/examples#important-note for the examples corresponding to other '
                'versions of HuggingFace Transformers.'	)


