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    ):
         __lowerCAmelCase    :				Dict    =      MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING
         __lowerCAmelCase    :				Union[str, Any]    =      TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING
  
  
  
  
         def 							__UpperCamelCase       (     self   ,   snake_case_   ,   snake_case_   ,   snake_case_  ):
           if isinstance(model.config   ,   snake_case_  ):
             _lowerCAmelCase				,					_lowerCAmelCase       :  Any   				=					list(tokenizer.lang_code_to_id.keys()  )[:2]
             _lowerCAmelCase       :  Tuple   				=					TranslationPipeline(model=snake_case_   ,   tokenizer=snake_case_   ,   src_lang=snake_case_   ,   tgt_lang=snake_case_  )
           else:
             _lowerCAmelCase       :  List[Any]   				=					TranslationPipeline(model=snake_case_   ,   tokenizer=snake_case_  )
           return translator, ["Some string", "Some other text"]
  
  
  
  
         def 							__UpperCamelCase       (     self   ,   snake_case_   ,   snake_case_  ):
           _lowerCAmelCase       :  Optional[int]   				=					translator("""Some string"""  )
           self.assertEqual(snake_case_   ,   [{"""translation_text""": ANY(snake_case_  )}]  )
  
           _lowerCAmelCase       :  str   				=					translator(["""Some string"""]  )
           self.assertEqual(snake_case_   ,   [{"""translation_text""": ANY(snake_case_  )}]  )
  
           _lowerCAmelCase       :  Dict   				=					translator(["""Some string""", """other string"""]  )
           self.assertEqual(snake_case_   ,   [{"""translation_text""": ANY(snake_case_  )}, {"""translation_text""": ANY(snake_case_  )}]  )
  
  
  
  
         @require_torch
         def 							__UpperCamelCase       (     self  ):
           _lowerCAmelCase       :  Tuple   				=					pipeline("""translation_en_to_ro"""   ,   model="""patrickvonplaten/t5-tiny-random"""   ,   framework="""pt"""  )
           _lowerCAmelCase       :  Any   				=					translator("""This is a test string"""   ,   max_length=2_0  )
           self.assertEqual(
               snake_case_   ,   [
                   {
                       """translation_text""": (
                           """Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide"""
                           """ Beide Beide"""
                       )
                   }
               ]   ,   )
  
  
  
  
         @require_tf
         def 							__UpperCamelCase       (     self  ):
           _lowerCAmelCase       :  Tuple   				=					pipeline("""translation_en_to_ro"""   ,   model="""patrickvonplaten/t5-tiny-random"""   ,   framework="""tf"""  )
           _lowerCAmelCase       :  List[str]   				=					translator("""This is a test string"""   ,   max_length=2_0  )
           self.assertEqual(
               snake_case_   ,   [
                   {
                       """translation_text""": (
                           """Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide"""
                           """ Beide Beide"""
                       )
                   }
               ]   ,   )
  
  
  
  
         @require_torch
         def 							__UpperCamelCase       (     self  ):
           _lowerCAmelCase       :  List[Any]   				=					pipeline("""translation_en_to_de"""   ,   model="""patrickvonplaten/t5-tiny-random"""   ,   framework="""pt"""  )
           _lowerCAmelCase       :  Union[str, Any]   				=					translator("""This is a test string"""   ,   max_length=2_0  )
           self.assertEqual(
               snake_case_   ,   [
                   {
                       """translation_text""": (
                           """monoton monoton monoton monoton monoton monoton monoton monoton monoton monoton urine urine"""
                           """ urine urine urine urine urine urine urine"""
                       )
                   }
               ]   ,   )
  
  
  
  
  
  
  
         @require_tf
         def 							__UpperCamelCase       (     self  ):
           _lowerCAmelCase       :  int   				=					pipeline("""translation_en_to_de"""   ,   model="""patrickvonplaten/t5-tiny-random"""   ,   framework="""tf"""  )
           _lowerCAmelCase       :  List[Any]   				=					translator("""This is a test string"""   ,   max_length=2_0  )
           self.assertEqual(
               snake_case_   ,   [
                   {
                       """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    ):
  
  
  
  
         @require_torch
         @slow
         def 							__UpperCamelCase       (     self  ):
           # We don't provide a default for this pair
           with self.assertRaises(snake_case_  ):
             pipeline(task="""translation_cn_to_ar"""  )
  
           # but we do for this one
           _lowerCAmelCase       :  Any   				=					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 							__UpperCamelCase       (     self  ):
           _lowerCAmelCase       :  List[Any]   				=					MBartForConditionalGeneration.from_pretrained("""facebook/mbart-large-50-many-to-many-mmt"""  )
           _lowerCAmelCase       :  Union[str, Any]   				=					MBartaaTokenizerFast.from_pretrained("""facebook/mbart-large-50-many-to-many-mmt"""  )
  
           _lowerCAmelCase       :  Any   				=					pipeline(task="""translation"""   ,   model=snake_case_   ,   tokenizer=snake_case_  )
           # Missing src_lang, tgt_lang
           with self.assertRaises(snake_case_  ):
             translator("""This is a test"""  )
  
           _lowerCAmelCase       :  Optional[int]   				=					translator("""This is a test"""   ,   src_lang="""en_XX"""   ,   tgt_lang="""ar_AR"""  )
           self.assertEqual(snake_case_   ,   [{"""translation_text""": """هذا إختبار"""}]  )
  
           _lowerCAmelCase       :  List[Any]   				=					translator("""This is a test"""   ,   src_lang="""en_XX"""   ,   tgt_lang="""hi_IN"""  )
           self.assertEqual(snake_case_   ,   [{"""translation_text""": """यह एक परीक्षण है"""}]  )
  
           # src_lang, tgt_lang can be defined at pipeline call time
           _lowerCAmelCase       :  List[str]   				=					pipeline(task="""translation"""   ,   model=snake_case_   ,   tokenizer=snake_case_   ,   src_lang="""en_XX"""   ,   tgt_lang="""ar_AR"""  )
           _lowerCAmelCase       :  List[str]   				=					translator("""This is a test"""  )
           self.assertEqual(snake_case_   ,   [{"""translation_text""": """هذا إختبار"""}]  )
  
  
  
  
         @require_torch
         def 							__UpperCamelCase       (     self  ):
           _lowerCAmelCase       :  List[str]   				=					"""patrickvonplaten/t5-tiny-random"""
           _lowerCAmelCase       :  str   				=					pipeline(task="""translation_cn_to_ar"""   ,   model=snake_case_  )
           self.assertEqual(translator._preprocess_params["""src_lang"""]   ,   """cn"""  )
           self.assertEqual(translator._preprocess_params["""tgt_lang"""]   ,   """ar"""  )
  
  
  
  
         @require_torch
         def 							__UpperCamelCase       (     self  ):
           _lowerCAmelCase       :  List[str]   				=					"""patrickvonplaten/t5-tiny-random"""
           with pytest.warns(snake_case_   ,   match=r""".*translation_en_to_de.*"""  ):
             _lowerCAmelCase       :  Dict   				=					pipeline(task="""translation"""   ,   model=snake_case_  )
           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 							__UpperCamelCase       (     self  ):
           with self.assertRaises(snake_case_  ):
             pipeline(task="""translation"""  )
  
  
  
style_context: 
  '''simple docstring'''
  
  from typing import TYPE_CHECKING
  
  from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available
  
  
  UpperCamelCase_     			=       {
      """configuration_deformable_detr""": ["""DEFORMABLE_DETR_PRETRAINED_CONFIG_ARCHIVE_MAP""", """DeformableDetrConfig"""],
  }
  
  try:
       if not is_vision_available():
            raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
       pass
  else:
       UpperCamelCase_     			=       ["""DeformableDetrFeatureExtractor"""]
       UpperCamelCase_     			=       ["""DeformableDetrImageProcessor"""]
  
  try:
       if not is_torch_available():
            raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
       pass
  else:
       UpperCamelCase_     			=       [
           """DEFORMABLE_DETR_PRETRAINED_MODEL_ARCHIVE_LIST""",
           """DeformableDetrForObjectDetection""",
           """DeformableDetrModel""",
           """DeformableDetrPreTrainedModel""",
       ]
  
  
  if TYPE_CHECKING:
       from .configuration_deformable_detr import DEFORMABLE_DETR_PRETRAINED_CONFIG_ARCHIVE_MAP, DeformableDetrConfig
  
       try:
            if not is_vision_available():
                 raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
            pass
       else:
            from .feature_extraction_deformable_detr import DeformableDetrFeatureExtractor
            from .image_processing_deformable_detr import DeformableDetrImageProcessor
  
       try:
            if not is_torch_available():
                 raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
            pass
       else:
            from .modeling_deformable_detr import (
                DEFORMABLE_DETR_PRETRAINED_MODEL_ARCHIVE_LIST,
                DeformableDetrForObjectDetection,
                DeformableDetrModel,
                DeformableDetrPreTrainedModel,
            )
  
  else:
       import sys
  
       UpperCamelCase_     			=       _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)
  
  
  