code: 
  
  
  '''simple docstring'''
  
  
  
  
  
  import unittest
  
  import pytest
  
  from transformers import (
      MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING,
      TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING,
      MBartaaTokenizerFast,
      MBartConfig,
      MBartForConditionalGeneration,
      TranslationPipeline,
      pipeline,
  )
  from transformers.testing_utils import is_pipeline_test, require_tf, require_torch, slow
  
  from .test_pipelines_common import ANY
  @is_pipeline_test
  class 	a__				(				unittest.TestCase      ):
  
  
  
  
  
  			'''simple docstring'''
  
  			A	:							List[str]							= MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING
  			A	:							int							= TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING
  			def 				lowerCAmelCase    (     self       : Optional[int] ,						lowerCAmelCase_       : Optional[int] ,						lowerCAmelCase_       : str ,						lowerCAmelCase_       : List[str]  )			->		Dict:
  						if isinstance(model.config ,						lowerCAmelCase_  ):
  									__A,  __A=  list(tokenizer.lang_code_to_id.keys()  )[:2]
  									__A=  TranslationPipeline(model=lowerCAmelCase_ ,						tokenizer=lowerCAmelCase_ ,						src_lang=lowerCAmelCase_ ,						tgt_lang=lowerCAmelCase_  )
  						else:
  									__A=  TranslationPipeline(model=lowerCAmelCase_ ,						tokenizer=lowerCAmelCase_  )
  						return translator, ["Some string", "Some other text"]
  			def 				lowerCAmelCase    (     self       : List[str] ,						lowerCAmelCase_       : Tuple ,						lowerCAmelCase_       : Optional[int]  )			->		List[Any]:
  						__A=  translator('Some string'  )
  						self.assertEqual(lowerCAmelCase_ ,						[{'translation_text': ANY(lowerCAmelCase_  )}]  )
  
  						__A=  translator(['Some string']  )
  						self.assertEqual(lowerCAmelCase_ ,						[{'translation_text': ANY(lowerCAmelCase_  )}]  )
  
  						__A=  translator(['Some string', 'other string']  )
  						self.assertEqual(lowerCAmelCase_ ,						[{'translation_text': ANY(lowerCAmelCase_  )}, {'translation_text': ANY(lowerCAmelCase_  )}]  )
  			@require_torch
  			def 				lowerCAmelCase    (     self       : Union[str, Any]  )			->		Optional[Any]:
  						__A=  pipeline('translation_en_to_ro' ,						model='patrickvonplaten/t5-tiny-random' ,						framework='pt'  )
  						__A=  translator('This is a test string' ,						max_length=20  )
  						self.assertEqual(
  						    lowerCAmelCase_ ,						[
  						        {
  						            'translation_text': (
  						                'Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide'
  						                ' Beide Beide'
  						            )
  						        }
  						    ] ,						)
  			@require_tf
  			def 				lowerCAmelCase    (     self       : Dict  )			->		List[Any]:
  						__A=  pipeline('translation_en_to_ro' ,						model='patrickvonplaten/t5-tiny-random' ,						framework='tf'  )
  						__A=  translator('This is a test string' ,						max_length=20  )
  						self.assertEqual(
  						    lowerCAmelCase_ ,						[
  						        {
  						            'translation_text': (
  						                'Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide'
  						                ' Beide Beide'
  						            )
  						        }
  						    ] ,						)
  			@require_torch
  			def 				lowerCAmelCase    (     self       : Union[str, Any]  )			->		List[str]:
  						__A=  pipeline('translation_en_to_de' ,						model='patrickvonplaten/t5-tiny-random' ,						framework='pt'  )
  						__A=  translator('This is a test string' ,						max_length=20  )
  						self.assertEqual(
  						    lowerCAmelCase_ ,						[
  						        {
  						            'translation_text': (
  						                'monoton monoton monoton monoton monoton monoton monoton monoton monoton monoton urine urine'
  						                ' urine urine urine urine urine urine urine'
  						            )
  						        }
  						    ] ,						)
  
  			@require_tf
  			def 				lowerCAmelCase    (     self       : int  )			->		Optional[int]:
  						__A=  pipeline('translation_en_to_de' ,						model='patrickvonplaten/t5-tiny-random' ,						framework='tf'  )
  						__A=  translator('This is a test string' ,						max_length=20  )
  						self.assertEqual(
  						    lowerCAmelCase_ ,						[
  						        {
  						            'translation_text': (
  						                'monoton monoton monoton monoton monoton monoton monoton monoton monoton monoton urine urine'
  						                ' urine urine urine urine urine urine urine'
  						            )
  						        }
  						    ] ,						)
  
  
  class 	a__				(				unittest.TestCase      ):
  
  
  
  
  
  			'''simple docstring'''
  
  			@require_torch
  			@slow
  			def 				lowerCAmelCase    (     self       : Tuple  )			->		Union[str, Any]:
  						# We don't provide a default for this pair
  						with self.assertRaises(lowerCAmelCase_  ):
  									pipeline(task='translation_cn_to_ar'  )
  
  						# but we do for this one
  						__A=  pipeline(task='translation_en_to_de'  )
  						self.assertEqual(translator._preprocess_params['src_lang'] ,						'en'  )
  						self.assertEqual(translator._preprocess_params['tgt_lang'] ,						'de'  )
  			@require_torch
  			@slow
  			def 				lowerCAmelCase    (     self       : List[Any]  )			->		Union[str, Any]:
  						__A=  MBartForConditionalGeneration.from_pretrained('facebook/mbart-large-50-many-to-many-mmt'  )
  						__A=  MBartaaTokenizerFast.from_pretrained('facebook/mbart-large-50-many-to-many-mmt'  )
  
  						__A=  pipeline(task='translation' ,						model=lowerCAmelCase_ ,						tokenizer=lowerCAmelCase_  )
  						# Missing src_lang, tgt_lang
  						with self.assertRaises(lowerCAmelCase_  ):
  									translator('This is a test'  )
  
  						__A=  translator('This is a test' ,						src_lang='en_XX' ,						tgt_lang='ar_AR'  )
  						self.assertEqual(lowerCAmelCase_ ,						[{'translation_text': 'هذا إختبار'}]  )
  
  						__A=  translator('This is a test' ,						src_lang='en_XX' ,						tgt_lang='hi_IN'  )
  						self.assertEqual(lowerCAmelCase_ ,						[{'translation_text': 'यह एक परीक्षण है'}]  )
  
  						# src_lang, tgt_lang can be defined at pipeline call time
  						__A=  pipeline(task='translation' ,						model=lowerCAmelCase_ ,						tokenizer=lowerCAmelCase_ ,						src_lang='en_XX' ,						tgt_lang='ar_AR'  )
  						__A=  translator('This is a test'  )
  						self.assertEqual(lowerCAmelCase_ ,						[{'translation_text': 'هذا إختبار'}]  )
  			@require_torch
  			def 				lowerCAmelCase    (     self       : Union[str, Any]  )			->		List[str]:
  						__A=  'patrickvonplaten/t5-tiny-random'
  						__A=  pipeline(task='translation_cn_to_ar' ,						model=lowerCAmelCase_  )
  						self.assertEqual(translator._preprocess_params['src_lang'] ,						'cn'  )
  						self.assertEqual(translator._preprocess_params['tgt_lang'] ,						'ar'  )
  			@require_torch
  			def 				lowerCAmelCase    (     self       : List[Any]  )			->		List[Any]:
  						__A=  'patrickvonplaten/t5-tiny-random'
  						with pytest.warns(lowerCAmelCase_ ,						match=r'.*translation_en_to_de.*'  ):
  									__A=  pipeline(task='translation' ,						model=lowerCAmelCase_  )
  						self.assertEqual(translator.task ,						'translation_en_to_de'  )
  						self.assertEqual(translator._preprocess_params['src_lang'] ,						'en'  )
  						self.assertEqual(translator._preprocess_params['tgt_lang'] ,						'de'  )
  
  			@require_torch
  			def 				lowerCAmelCase    (     self       : Any  )			->		Any:
  						with self.assertRaises(lowerCAmelCase_  ):
  									pipeline(task='translation'  )
  
  
  
  
style_context: 
  
  
  '''simple docstring'''
  
  
  
  
  
  from collections import OrderedDict
  from typing import Mapping
  
  from ...configuration_utils import PretrainedConfig
  from ...onnx import OnnxConfig
  from ...utils import logging
  
  
  UpperCAmelCase__      =							logging.get_logger(__name__)
  
  UpperCAmelCase__      =							{
      '''google/mobilebert-uncased''': '''https://huggingface.co/google/mobilebert-uncased/resolve/main/config.json'''
  }
  class 	a__				(				a_      ):
  
  
  
  
  
  			'''simple docstring'''
  
  			A	:							int							= MOBILEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP
  			A	:							Optional[int]							= '''mobilebert'''
  			def __init__(     self       : Optional[int] ,						lowerCAmelCase_       : str=30_522 ,						lowerCAmelCase_       : List[Any]=512 ,						lowerCAmelCase_       : Optional[int]=24 ,						lowerCAmelCase_       : str=4 ,						lowerCAmelCase_       : List[str]=512 ,						lowerCAmelCase_       : List[str]="relu" ,						lowerCAmelCase_       : Dict=0.0 ,						lowerCAmelCase_       : List[Any]=0.1 ,						lowerCAmelCase_       : Optional[Any]=512 ,						lowerCAmelCase_       : str=2 ,						lowerCAmelCase_       : Dict=0.02 ,						lowerCAmelCase_       : Any=1E-12 ,						lowerCAmelCase_       : List[Any]=0 ,						lowerCAmelCase_       : Union[str, Any]=128 ,						lowerCAmelCase_       : Any=True ,						lowerCAmelCase_       : Optional[Any]=True ,						lowerCAmelCase_       : List[Any]=128 ,						lowerCAmelCase_       : Dict=False ,						lowerCAmelCase_       : Tuple=True ,						lowerCAmelCase_       : Any=4 ,						lowerCAmelCase_       : Optional[Any]="no_norm" ,						lowerCAmelCase_       : Optional[Any]=True ,						lowerCAmelCase_       : Union[str, Any]=None ,						**lowerCAmelCase_       : Union[str, Any] ,						)			->		List[Any]:
  						super().__init__(pad_token_id=lowerCAmelCase_ ,						**lowerCAmelCase_  )
  
  						__A=  vocab_size
  						__A=  hidden_size
  						__A=  num_hidden_layers
  						__A=  num_attention_heads
  						__A=  hidden_act
  						__A=  intermediate_size
  						__A=  hidden_dropout_prob
  						__A=  attention_probs_dropout_prob
  						__A=  max_position_embeddings
  						__A=  type_vocab_size
  						__A=  initializer_range
  						__A=  layer_norm_eps
  						__A=  embedding_size
  						__A=  trigram_input
  						__A=  use_bottleneck
  						__A=  intra_bottleneck_size
  						__A=  use_bottleneck_attention
  						__A=  key_query_shared_bottleneck
  						__A=  num_feedforward_networks
  						__A=  normalization_type
  						__A=  classifier_activation
  
  						if self.use_bottleneck:
  									__A=  intra_bottleneck_size
  						else:
  									__A=  hidden_size
  
  						__A=  classifier_dropout
  
  
  class 	a__				(				a_      ):
  
  
  
  
  
  			'''simple docstring'''
  
  			@property
  			def 				lowerCAmelCase    (     self       : List[str]  )			->		Mapping[str, Mapping[int, str]]:
  						if self.task == "multiple-choice":
  									__A=  {0: 'batch', 1: 'choice', 2: 'sequence'}
  						else:
  									__A=  {0: 'batch', 1: 'sequence'}
  						return OrderedDict(
  						    [
  						        ('input_ids', dynamic_axis),
  						        ('attention_mask', dynamic_axis),
  						        ('token_type_ids', dynamic_axis),
  						    ]  )
  
  
  
  