


'''simple docstring'''



import copy
from typing import TYPE_CHECKING, Any, Mapping, Optional, OrderedDict

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging
from ..auto.configuration_auto import AutoConfig


if TYPE_CHECKING:
		from ... import PreTrainedTokenizerBase, TensorType

__A		=logging.get_logger(__name__)


class 						_snake_case    (   lowerCamelCase__		):
					lowerCAmelCase					:Optional[int]            =    'vision-encoder-decoder'
					lowerCAmelCase					:Union[str, Any]            =    True




					def __init__(					self							,							**_lowerCamelCase):
								super().__init__(**lowercase__)
								if "encoder" not in kwargs or "decoder" not in kwargs:
											raise ValueError(
											    f'''A configuraton of type {self.model_type} cannot be instantiated because '''
											    f'''not both `encoder` and `decoder` sub-configurations are passed, but only {kwargs}''')

								UpperCAmelCase__     :    Any         =   kwargs.pop("""encoder""")
								UpperCAmelCase__     :    Dict         =   encoder_config.pop("""model_type""")
								UpperCAmelCase__     :    Dict         =   kwargs.pop("""decoder""")
								UpperCAmelCase__     :    Optional[Any]         =   decoder_config.pop("""model_type""")

								UpperCAmelCase__     :    str         =   AutoConfig.for_model(lowercase__							,							**lowercase__)
								UpperCAmelCase__     :    Any         =   AutoConfig.for_model(lowercase__							,							**lowercase__)
								UpperCAmelCase__     :    List[str]         =   True




					@classmethod
					def  snake_case__  (					cls							,							_lowerCamelCase							,							_lowerCamelCase							,							**_lowerCamelCase):
								logger.info("""Setting `config.is_decoder=True` and `config.add_cross_attention=True` for decoder_config""")
								UpperCAmelCase__     :    Dict         =   True
								UpperCAmelCase__     :    Optional[Any]         =   True

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




					def  snake_case__  (					self):
								UpperCAmelCase__     :    Any         =   copy.deepcopy(self.__dict__)
								UpperCAmelCase__     :    List[Any]         =   self.encoder.to_dict()
								UpperCAmelCase__     :    List[Any]         =   self.decoder.to_dict()
								UpperCAmelCase__     :    Any         =   self.__class__.model_type
								return output


class 						_snake_case    (   lowerCamelCase__		):
					lowerCAmelCase					:Dict            =    version.parse('''1.11'''		)




					@property
					def  snake_case__  (					self):
								return OrderedDict(
								    [
								        ("""pixel_values""", {0: """batch""", 1: """num_channels""", 2: """height""", 3: """width"""}),
								    ])




					@property
					def  snake_case__  (					self):
								return 1e-4




					@property
					def  snake_case__  (					self):
								return OrderedDict({"""last_hidden_state""": {0: """batch""", 1: """encoder_sequence"""}})


class 						_snake_case    (   lowerCamelCase__		):




					@property
					def  snake_case__  (					self):
								UpperCAmelCase__     :    int         =   OrderedDict()
								UpperCAmelCase__     :    str         =   {0: """batch""", 1: """past_decoder_sequence + sequence"""}
								UpperCAmelCase__     :    List[str]         =   {0: """batch""", 1: """past_decoder_sequence + sequence"""}
								UpperCAmelCase__     :    List[Any]         =   {0: """batch""", 1: """encoder_sequence"""}

								return common_inputs




					def  snake_case__  (					self							,							_lowerCamelCase							,							_lowerCamelCase = -1							,							_lowerCamelCase = -1							,							_lowerCamelCase = False							,							_lowerCamelCase = None							,							):
								import torch

								UpperCAmelCase__     :    Tuple         =   OrderedDict()

								UpperCAmelCase__     :    List[Any]         =   super().generate_dummy_inputs(
								    lowercase__							,							batch_size=lowercase__							,							seq_length=lowercase__							,							is_pair=lowercase__							,							framework=lowercase__)

								UpperCAmelCase__      ,				UpperCAmelCase__     :    Any         =   dummy_input["""input_ids"""].shape
								UpperCAmelCase__     :    Tuple         =   (batch, encoder_sequence, self._config.encoder_hidden_size)
								UpperCAmelCase__     :    Optional[int]         =   dummy_input.pop("""input_ids""")
								UpperCAmelCase__     :    str         =   dummy_input.pop("""attention_mask""")
								UpperCAmelCase__     :    List[Any]         =   torch.zeros(lowercase__)

								return common_inputs


class 						_snake_case    (   lowerCamelCase__		):




					@property
					def  snake_case__  (					self):
								pass




					def  snake_case__  (					self							,							_lowerCamelCase):
								return VisionEncoderDecoderEncoderOnnxConfig(lowercase__)




					def  snake_case__  (					self							,							_lowerCamelCase							,							_lowerCamelCase							,							_lowerCamelCase = "default"):
								UpperCAmelCase__     :    Any         =   encoder_config.hidden_size
								return VisionEncoderDecoderDecoderOnnxConfig(lowercase__							,							lowercase__)


'''simple docstring'''






from typing import TYPE_CHECKING

from ...file_utils import _LazyModule, is_torch_available
from ...utils import OptionalDependencyNotAvailable


lowerCAmelCase__											=	{
    '''configuration_gpt_neox_japanese''': ['''GPT_NEOX_JAPANESE_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''GPTNeoXJapaneseConfig'''],
    '''tokenization_gpt_neox_japanese''': ['''GPTNeoXJapaneseTokenizer'''],
}

try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 lowerCAmelCase__											=	[
     '''GPT_NEOX_JAPANESE_PRETRAINED_MODEL_ARCHIVE_LIST''',
     '''GPTNeoXJapaneseForCausalLM''',
     '''GPTNeoXJapaneseLayer''',
     '''GPTNeoXJapaneseModel''',
     '''GPTNeoXJapanesePreTrainedModel''',
 ]


if TYPE_CHECKING:
 from .configuration_gpt_neox_japanese import GPT_NEOX_JAPANESE_PRETRAINED_CONFIG_ARCHIVE_MAP, GPTNeoXJapaneseConfig
 from .tokenization_gpt_neox_japanese import GPTNeoXJapaneseTokenizer

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_gpt_neox_japanese import (
      GPT_NEOX_JAPANESE_PRETRAINED_MODEL_ARCHIVE_LIST,
      GPTNeoXJapaneseForCausalLM,
      GPTNeoXJapaneseLayer,
      GPTNeoXJapaneseModel,
      GPTNeoXJapanesePreTrainedModel,
  )


else:
 import sys

 lowerCAmelCase__											=	_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)

