

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

_SCREAMING_SNAKE_CASE					:  Union[str, Any]             =      logging.get_logger(__name__)






class 	UpperCAmelCase__		(	A__	):






  """simple docstring"""


  a									= "vision-encoder-decoder"
  a									= True






  def __init__(							self						:		Optional[Any]     ,       **__lowerCamelCase						:		Union[str, Any] )		->							int:
       super().__init__(**__lowerCamelCase )
       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__   =   kwargs.pop('''encoder''' )
       SCREAMING_SNAKE_CASE__   =   encoder_config.pop('''model_type''' )
       SCREAMING_SNAKE_CASE__   =   kwargs.pop('''decoder''' )
       SCREAMING_SNAKE_CASE__   =   decoder_config.pop('''model_type''' )

       SCREAMING_SNAKE_CASE__   =   AutoConfig.for_model(__lowerCamelCase     ,       **__lowerCamelCase )
       SCREAMING_SNAKE_CASE__   =   AutoConfig.for_model(__lowerCamelCase     ,       **__lowerCamelCase )
       SCREAMING_SNAKE_CASE__   =   True






  @classmethod
  def 				lowercase_		(							cls						:		Union[str, Any]     ,       __lowerCamelCase						:		PretrainedConfig     ,       __lowerCamelCase						:		PretrainedConfig     ,       **__lowerCamelCase						:		Optional[int] )		->							PretrainedConfig:
       logger.info('''Setting `config.is_decoder=True` and `config.add_cross_attention=True` for decoder_config''' )
       SCREAMING_SNAKE_CASE__   =   True
       SCREAMING_SNAKE_CASE__   =   True

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







  def 				lowercase_		(							self						:		Tuple )		->							Union[str, Any]:
       SCREAMING_SNAKE_CASE__   =   copy.deepcopy(self.__dict__ )
       SCREAMING_SNAKE_CASE__   =   self.encoder.to_dict()
       SCREAMING_SNAKE_CASE__   =   self.decoder.to_dict()
       SCREAMING_SNAKE_CASE__   =   self.__class__.model_type
       return output






class 	UpperCAmelCase__		(	A__	):






  """simple docstring"""


  a									= version.parse("1.11"	)






  @property
  def 				lowercase_		(							self						:		Any )		->							Mapping[str, Mapping[int, str]]:
       return OrderedDict(
           [
               ('''pixel_values''', {0: '''batch''', 1: '''num_channels''', 2: '''height''', 3: '''width'''}),
           ] )






  @property
  def 				lowercase_		(							self						:		List[str] )		->							float:
       return 1e-4







  @property
  def 				lowercase_		(							self						:		List[str] )		->							Mapping[str, Mapping[int, str]]:
       return OrderedDict({'''last_hidden_state''': {0: '''batch''', 1: '''encoder_sequence'''}} )






class 	UpperCAmelCase__		(	A__	):






  """simple docstring"""


  @property
  def 				lowercase_		(							self						:		Optional[Any] )		->							Mapping[str, Mapping[int, str]]:
       SCREAMING_SNAKE_CASE__   =   OrderedDict()
       SCREAMING_SNAKE_CASE__   =   {0: '''batch''', 1: '''past_decoder_sequence + sequence'''}
       SCREAMING_SNAKE_CASE__   =   {0: '''batch''', 1: '''past_decoder_sequence + sequence'''}
       SCREAMING_SNAKE_CASE__   =   {0: '''batch''', 1: '''encoder_sequence'''}

       return common_inputs







  def 				lowercase_		(							self						:		List[Any]     ,       __lowerCamelCase						:		"PreTrainedTokenizerBase"     ,       __lowerCamelCase						:		int = -1     ,       __lowerCamelCase						:		int = -1     ,       __lowerCamelCase						:		bool = False     ,       __lowerCamelCase						:		Optional["TensorType"] = None     ,       )		->							Mapping[str, Any]:
       import torch

       SCREAMING_SNAKE_CASE__   =   OrderedDict()

       SCREAMING_SNAKE_CASE__   =   super().generate_dummy_inputs(
           __lowerCamelCase     ,       batch_size=__lowerCamelCase     ,       seq_length=__lowerCamelCase     ,       is_pair=__lowerCamelCase     ,       framework=__lowerCamelCase )

       SCREAMING_SNAKE_CASE__,SCREAMING_SNAKE_CASE__   =   dummy_input['''input_ids'''].shape
       SCREAMING_SNAKE_CASE__   =   (batch, encoder_sequence, self._config.encoder_hidden_size)
       SCREAMING_SNAKE_CASE__   =   dummy_input.pop('''input_ids''' )
       SCREAMING_SNAKE_CASE__   =   dummy_input.pop('''attention_mask''' )
       SCREAMING_SNAKE_CASE__   =   torch.zeros(__lowerCamelCase )

       return common_inputs






class 	UpperCAmelCase__		(	A__	):






  """simple docstring"""


  @property
  def 				lowercase_		(							self						:		Any )		->							None:
       pass






  def 				lowercase_		(							self						:		Optional[Any]     ,       __lowerCamelCase						:		PretrainedConfig )		->							OnnxConfig:
       return VisionEncoderDecoderEncoderOnnxConfig(__lowerCamelCase )







  def 				lowercase_		(							self						:		Union[str, Any]     ,       __lowerCamelCase						:		PretrainedConfig     ,       __lowerCamelCase						:		PretrainedConfig     ,       __lowerCamelCase						:		str = "default" )		->							OnnxConfig:
       SCREAMING_SNAKE_CASE__   =   encoder_config.hidden_size
       return VisionEncoderDecoderDecoderOnnxConfig(__lowerCamelCase     ,       __lowerCamelCase )





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


_SCREAMING_SNAKE_CASE					:  Any             =      logging.get_logger(__name__)

_SCREAMING_SNAKE_CASE					:  Optional[Any]             =      {
    '''google/vivit-b-16x2-kinetics400''': (
        '''https://huggingface.co/google/vivit-b-16x2-kinetics400/resolve/main/config.json'''
    ),
    # See all Vivit models at https://huggingface.co/models?filter=vivit
}






class 	UpperCAmelCase__		(	A__	):






  """simple docstring"""


  a									= "vivit"






  def __init__(							self						:		str     ,       __lowerCamelCase						:		List[Any]=224     ,       __lowerCamelCase						:		Optional[int]=32     ,       __lowerCamelCase						:		Tuple=[2, 16, 16]     ,       __lowerCamelCase						:		Union[str, Any]=3     ,       __lowerCamelCase						:		Optional[Any]=768     ,       __lowerCamelCase						:		Any=12     ,       __lowerCamelCase						:		Optional[Any]=12     ,       __lowerCamelCase						:		List[str]=3072     ,       __lowerCamelCase						:		Any="gelu_fast"     ,       __lowerCamelCase						:		Union[str, Any]=0.0     ,       __lowerCamelCase						:		int=0.0     ,       __lowerCamelCase						:		str=0.02     ,       __lowerCamelCase						:		Any=1e-06     ,       __lowerCamelCase						:		Dict=True     ,       **__lowerCamelCase						:		Any     ,       )		->							List[str]:
       SCREAMING_SNAKE_CASE__   =   hidden_size
       SCREAMING_SNAKE_CASE__   =   num_hidden_layers
       SCREAMING_SNAKE_CASE__   =   num_attention_heads
       SCREAMING_SNAKE_CASE__   =   intermediate_size
       SCREAMING_SNAKE_CASE__   =   hidden_act
       SCREAMING_SNAKE_CASE__   =   hidden_dropout_prob
       SCREAMING_SNAKE_CASE__   =   attention_probs_dropout_prob
       SCREAMING_SNAKE_CASE__   =   initializer_range
       SCREAMING_SNAKE_CASE__   =   layer_norm_eps

       SCREAMING_SNAKE_CASE__   =   image_size
       SCREAMING_SNAKE_CASE__   =   num_frames
       SCREAMING_SNAKE_CASE__   =   tubelet_size
       SCREAMING_SNAKE_CASE__   =   num_channels
       SCREAMING_SNAKE_CASE__   =   qkv_bias

       super().__init__(**__lowerCamelCase )


