
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

lowercase_ 				=			logging.get_logger(__name__)





class     __UpperCamelCase (							__a       ):






     """simple docstring"""







     lowerCAmelCase_							   =			'''vision-encoder-decoder'''
     lowerCAmelCase_							   =			True



     def __init__(				self							:							Union[str, Any]     ,						**_A							:							Dict ):







       """simple docstring"""




       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}''' )

       __SCREAMING_SNAKE_CASE      :	List[str]					=		kwargs.pop('''encoder''' )
       __SCREAMING_SNAKE_CASE      :	Tuple					=		encoder_config.pop('''model_type''' )
       __SCREAMING_SNAKE_CASE      :	Dict					=		kwargs.pop('''decoder''' )
       __SCREAMING_SNAKE_CASE      :	Dict					=		decoder_config.pop('''model_type''' )

       __SCREAMING_SNAKE_CASE      :	int					=		AutoConfig.for_model(lowercase_     ,						**lowercase_ )
       __SCREAMING_SNAKE_CASE      :	List[str]					=		AutoConfig.for_model(lowercase_     ,						**lowercase_ )
       __SCREAMING_SNAKE_CASE      :	List[str]					=		True



     @classmethod
     def  UpperCAmelCase__							(				cls							:							Optional[Any]     ,						_A							:							PretrainedConfig     ,						_A							:							PretrainedConfig     ,						**_A							:							Tuple ):







       """simple docstring"""




       logger.info('''Setting `config.is_decoder=True` and `config.add_cross_attention=True` for decoder_config''' )
       __SCREAMING_SNAKE_CASE      :	str					=		True
       __SCREAMING_SNAKE_CASE      :	Any					=		True

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




     def  UpperCAmelCase__							(				self							:							List[str] ):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE      :	Any					=		copy.deepcopy(self.__dict__ )
       __SCREAMING_SNAKE_CASE      :	Optional[Any]					=		self.encoder.to_dict()
       __SCREAMING_SNAKE_CASE      :	Optional[Any]					=		self.decoder.to_dict()
       __SCREAMING_SNAKE_CASE      :	Optional[int]					=		self.__class__.model_type
       return output






class     __UpperCamelCase (							__a       ):






     """simple docstring"""







     lowerCAmelCase_							   =			version.parse('''1.11'''       )



     @property
     def  UpperCAmelCase__							(				self							:							Dict ):







       """simple docstring"""




       return OrderedDict(
           [
               ('''pixel_values''', {0: '''batch''', 1: '''num_channels''', 2: '''height''', 3: '''width'''}),
           ] )



     @property
     def  UpperCAmelCase__							(				self							:							Dict ):







       """simple docstring"""




       return 1e-4




     @property
     def  UpperCAmelCase__							(				self							:							Optional[Any] ):







       """simple docstring"""




       return OrderedDict({'''last_hidden_state''': {0: '''batch''', 1: '''encoder_sequence'''}} )






class     __UpperCamelCase (							__a       ):






     """simple docstring"""







     @property
     def  UpperCAmelCase__							(				self							:							Union[str, Any] ):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE      :	Optional[Any]					=		OrderedDict()
       __SCREAMING_SNAKE_CASE      :	List[str]					=		{0: '''batch''', 1: '''past_decoder_sequence + sequence'''}
       __SCREAMING_SNAKE_CASE      :	List[Any]					=		{0: '''batch''', 1: '''past_decoder_sequence + sequence'''}
       __SCREAMING_SNAKE_CASE      :	Any					=		{0: '''batch''', 1: '''encoder_sequence'''}

       return common_inputs




     def  UpperCAmelCase__							(				self							:							str     ,						_A							:							"PreTrainedTokenizerBase"     ,						_A							:							int = -1     ,						_A							:							int = -1     ,						_A							:							bool = False     ,						_A							:							Optional["TensorType"] = None     ,						):







       """simple docstring"""




       import torch

       __SCREAMING_SNAKE_CASE      :	Tuple					=		OrderedDict()

       __SCREAMING_SNAKE_CASE      :	Optional[Any]					=		super().generate_dummy_inputs(
           lowercase_     ,						batch_size=lowercase_     ,						seq_length=lowercase_     ,						is_pair=lowercase_     ,						framework=lowercase_ )

       __SCREAMING_SNAKE_CASE,		__SCREAMING_SNAKE_CASE      :	Any					=		dummy_input['''input_ids'''].shape
       __SCREAMING_SNAKE_CASE      :	int					=		(batch, encoder_sequence, self._config.encoder_hidden_size)
       __SCREAMING_SNAKE_CASE      :	Union[str, Any]					=		dummy_input.pop('''input_ids''' )
       __SCREAMING_SNAKE_CASE      :	Tuple					=		dummy_input.pop('''attention_mask''' )
       __SCREAMING_SNAKE_CASE      :	int					=		torch.zeros(lowercase_ )

       return common_inputs






class     __UpperCamelCase (							__a       ):






     """simple docstring"""







     @property
     def  UpperCAmelCase__							(				self							:							List[Any] ):







       """simple docstring"""




       pass



     def  UpperCAmelCase__							(				self							:							Any     ,						_A							:							PretrainedConfig ):







       """simple docstring"""




       return VisionEncoderDecoderEncoderOnnxConfig(lowercase_ )




     def  UpperCAmelCase__							(				self							:							Optional[Any]     ,						_A							:							PretrainedConfig     ,						_A							:							PretrainedConfig     ,						_A							:							str = "default" ):







       """simple docstring"""




       __SCREAMING_SNAKE_CASE      :	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


__snake_case						  =		{
    """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:
       __snake_case						  =		[
           """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

       __snake_case						  =		_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)

