

'''simple docstring'''
import copy

from ...configuration_utils import PretrainedConfig
from ...utils import logging


_snake_case         =  logging.get_logger(__name__)


class        a__  (							lowerCamelCase_  ):
   _SCREAMING_SNAKE_CASE   :					Tuple     	=							'encoder-decoder'
   _SCREAMING_SNAKE_CASE   :					List[str]     	=							True


   def __init__(			self      ,    **_UpperCamelCase  ):





      """simple docstring"""





      super().__init__(**_UpperCamelCase  )
      assert (
          "encoder" in kwargs and "decoder" in kwargs
      ), "Config has to be initialized with encoder and decoder config"
      _lowercase      :				Optional[int]      					=       kwargs.pop("encoder"  )
      _lowercase      :				Union[str, Any]      					=       encoder_config.pop("model_type"  )
      _lowercase      :				Union[str, Any]      					=       kwargs.pop("decoder"  )
      _lowercase      :				Dict      					=       decoder_config.pop("model_type"  )

      from ..auto.configuration_auto import AutoConfig

      _lowercase      :				List[Any]      					=       AutoConfig.for_model(_UpperCamelCase      ,    **_UpperCamelCase  )
      _lowercase      :				int      					=       AutoConfig.for_model(_UpperCamelCase      ,    **_UpperCamelCase  )
      _lowercase      :				Optional[int]      					=       True


   @classmethod
   def 						_lowerCamelCase       (			cls      ,    _UpperCamelCase      ,    _UpperCamelCase      ,    **_UpperCamelCase  ):





      """simple docstring"""





      logger.info("Set `config.is_decoder=True` and `config.add_cross_attention=True` for decoder_config"  )
      _lowercase      :				Dict      					=       True
      _lowercase      :				Union[str, Any]      					=       True

      return cls(encoder=encoder_config.to_dict()      ,    decoder=decoder_config.to_dict()      ,    **_UpperCamelCase  )






   def 						_lowerCamelCase       (			self  ):





      """simple docstring"""





      _lowercase      :				Union[str, Any]      					=       copy.deepcopy(self.__dict__  )
      _lowercase      :				str      					=       self.encoder.to_dict()
      _lowercase      :				Any      					=       self.decoder.to_dict()
      _lowercase      :				Union[str, Any]      					=       self.__class__.model_type
      return output









'''simple docstring'''
import doctest
import logging
import os
import unittest
from pathlib import Path
from typing import List, Union

import transformers
from transformers.testing_utils import require_tf, require_torch, slow


_snake_case         =  logging.getLogger()


@unittest.skip('Temporarily disable the doc tests.'  )
@require_torch
@require_tf
@slow
class        a__  (							unittest.TestCase  ):


   def 						_lowerCamelCase       (			self      ,    _UpperCamelCase      ,    _UpperCamelCase = None      ,    _UpperCamelCase = None      ,    _UpperCamelCase = None      ,    _UpperCamelCase = True      ,    ):





      """simple docstring"""





      _lowercase      :				str      					=       [file for file in os.listdir(_UpperCamelCase  ) if os.path.isfile(os.path.join(_UpperCamelCase      ,    _UpperCamelCase  )  )]

      if identifier is not None:
         _lowercase      :				str      					=       [file for file in files if identifier in file]

      if n_identifier is not None:
         if isinstance(_UpperCamelCase      ,    _UpperCamelCase  ):
            for n_ in n_identifier:
               _lowercase      :				Dict      					=       [file for file in files if n_ not in file]
         else:
            _lowercase      :				Optional[Any]      					=       [file for file in files if n_identifier not in file]

      _lowercase      :				Dict      					=       ignore_files or []
      ignore_files.append("__init__.py"  )
      _lowercase      :				List[str]      					=       [file for file in files if file not in ignore_files]

      for file in files:
         # Open all files
         print("Testing"      ,    _UpperCamelCase  )

         if only_modules:
            _lowercase      :				Optional[Any]      					=       file.split("."  )[0]
            try:
               _lowercase      :				Union[str, Any]      					=       getattr(_UpperCamelCase      ,    _UpperCamelCase  )
               _lowercase      :				Optional[int]      					=       doctest.DocTestSuite(_UpperCamelCase  )
               _lowercase      :				Tuple      					=       unittest.TextTestRunner().run(_UpperCamelCase  )
               self.assertIs(len(result.failures  )      ,    0  )
            except AttributeError:
               logger.info(f'''{module_identifier} is not a module.'''  )
         else:
            _lowercase      :				Optional[Any]      					=       doctest.testfile(str(".." / directory / file  )      ,    optionflags=doctest.ELLIPSIS  )
            self.assertIs(result.failed      ,    0  )


   def 						_lowerCamelCase       (			self  ):





      """simple docstring"""





      _lowercase      :				Tuple      					=       Path("src/transformers"  )
      _lowercase      :				str      					=       "modeling"
      _lowercase      :				Tuple      					=       [
          "modeling_ctrl.py",
          "modeling_tf_ctrl.py",
      ]
      self.analyze_directory(_UpperCamelCase      ,    identifier=_UpperCamelCase      ,    ignore_files=_UpperCamelCase  )


   def 						_lowerCamelCase       (			self  ):





      """simple docstring"""





      _lowercase      :				Optional[int]      					=       Path("src/transformers"  )
      _lowercase      :				Any      					=       "tokenization"
      self.analyze_directory(_UpperCamelCase      ,    identifier=_UpperCamelCase  )


   def 						_lowerCamelCase       (			self  ):





      """simple docstring"""





      _lowercase      :				Tuple      					=       Path("src/transformers"  )
      _lowercase      :				Optional[Any]      					=       "configuration"
      self.analyze_directory(_UpperCamelCase      ,    identifier=_UpperCamelCase  )


   def 						_lowerCamelCase       (			self  ):





      """simple docstring"""





      _lowercase      :				Union[str, Any]      					=       Path("src/transformers"  )
      _lowercase      :				List[Any]      					=       ["configuration", "modeling", "tokenization"]
      self.analyze_directory(_UpperCamelCase      ,    n_identifier=_UpperCamelCase  )






   def 						_lowerCamelCase       (			self  ):





      """simple docstring"""





      _lowercase      :				Dict      					=       Path("docs/source"  )
      _lowercase      :				int      					=       ["favicon.ico"]
      self.analyze_directory(_UpperCamelCase      ,    ignore_files=_UpperCamelCase      ,    only_modules=_UpperCamelCase  )






