

'''simple docstring'''



from typing import Mapping

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxSeqaSeqConfigWithPast
from ...utils import logging


UpperCAmelCase :       Optional[Any]			   =     logging.get_logger(__name__)

UpperCAmelCase :       List[Any]			   =     {
    't5-small': 'https://huggingface.co/t5-small/resolve/main/config.json',
    't5-base': 'https://huggingface.co/t5-base/resolve/main/config.json',
    't5-large': 'https://huggingface.co/t5-large/resolve/main/config.json',
    't5-3b': 'https://huggingface.co/t5-3b/resolve/main/config.json',
    't5-11b': 'https://huggingface.co/t5-11b/resolve/main/config.json',
}







class 						lowerCAmelCase__   (      a					):



 """simple docstring"""



 lowerCAmelCase__  					=      "t5"
 lowerCAmelCase__  					=      ["past_key_values"]
 lowerCAmelCase__  					=      {"hidden_size": "d_model", "num_attention_heads": "num_heads", "num_hidden_layers": "num_layers"}
 def __init__(		self					:       Optional[int]					,							__SCREAMING_SNAKE_CASE					:       List[Any]=32_128					,							__SCREAMING_SNAKE_CASE					:       Dict=512					,							__SCREAMING_SNAKE_CASE					:       List[str]=64					,							__SCREAMING_SNAKE_CASE					:       Tuple=2_048					,							__SCREAMING_SNAKE_CASE					:       Tuple=6					,							__SCREAMING_SNAKE_CASE					:       Tuple=None					,							__SCREAMING_SNAKE_CASE					:       Dict=8					,							__SCREAMING_SNAKE_CASE					:       Union[str, Any]=32					,							__SCREAMING_SNAKE_CASE					:       Optional[Any]=128					,							__SCREAMING_SNAKE_CASE					:       List[str]=0.1					,							__SCREAMING_SNAKE_CASE					:       Optional[Any]=1E-6					,							__SCREAMING_SNAKE_CASE					:       Optional[Any]=1.0					,							__SCREAMING_SNAKE_CASE					:       Any="relu"					,							__SCREAMING_SNAKE_CASE					:       List[Any]=True					,							__SCREAMING_SNAKE_CASE					:       Any=True					,							__SCREAMING_SNAKE_CASE					:       Dict=0					,							__SCREAMING_SNAKE_CASE					:       Tuple=1					,							**__SCREAMING_SNAKE_CASE					:       List[Any]					,							)  -> Tuple:


      """simple docstring"""




      __SCREAMING_SNAKE_CASE     =      vocab_size
      __SCREAMING_SNAKE_CASE     =      d_model
      __SCREAMING_SNAKE_CASE     =      d_kv
      __SCREAMING_SNAKE_CASE     =      d_ff
      __SCREAMING_SNAKE_CASE     =      num_layers
      __SCREAMING_SNAKE_CASE     =      (
          num_decoder_layers if num_decoder_layers is not None else self.num_layers
      )  # default = symmetry
      __SCREAMING_SNAKE_CASE     =      num_heads
      __SCREAMING_SNAKE_CASE     =      relative_attention_num_buckets
      __SCREAMING_SNAKE_CASE     =      relative_attention_max_distance
      __SCREAMING_SNAKE_CASE     =      dropout_rate
      __SCREAMING_SNAKE_CASE     =      layer_norm_epsilon
      __SCREAMING_SNAKE_CASE     =      initializer_factor
      __SCREAMING_SNAKE_CASE     =      feed_forward_proj
      __SCREAMING_SNAKE_CASE     =      use_cache

      __SCREAMING_SNAKE_CASE     =      self.feed_forward_proj.split("""-"""			)
      __SCREAMING_SNAKE_CASE     =      act_info[-1]
      __SCREAMING_SNAKE_CASE     =      act_info[0] == """gated"""

      if len(__SCREAMING_SNAKE_CASE			) > 1 and act_info[0] != "gated" or len(__SCREAMING_SNAKE_CASE			) > 2:
           raise ValueError(
               f'`feed_forward_proj`: {feed_forward_proj} is not a valid activation function of the dense layer.'
               """Please make sure `feed_forward_proj` is of the format `gated-{ACT_FN}` or `{ACT_FN}`, e.g. """
               """'gated-gelu' or 'relu'"""			)

      # for backwards compatibility
      if feed_forward_proj == "gated-gelu":
           __SCREAMING_SNAKE_CASE     =      """gelu_new"""

      super().__init__(
          pad_token_id=__SCREAMING_SNAKE_CASE					,							eos_token_id=__SCREAMING_SNAKE_CASE					,							is_encoder_decoder=__SCREAMING_SNAKE_CASE					,							**__SCREAMING_SNAKE_CASE					,							)







class 						lowerCAmelCase__   (      a					):



 """simple docstring"""



 @property
 def       UpperCAmelCase__		(		self					:       Optional[int]			)  -> Mapping[str, Mapping[int, str]]:


      """simple docstring"""




      __SCREAMING_SNAKE_CASE     =      {
          """input_ids""": {0: """batch""", 1: """encoder_sequence"""},
          """attention_mask""": {0: """batch""", 1: """encoder_sequence"""},
      }
      if self.use_past:
           __SCREAMING_SNAKE_CASE     =      """past_encoder_sequence + sequence"""
           __SCREAMING_SNAKE_CASE     =      {0: """batch"""}
           __SCREAMING_SNAKE_CASE     =      {0: """batch""", 1: """past_decoder_sequence + sequence"""}
      else:
           __SCREAMING_SNAKE_CASE     =      {0: """batch""", 1: """decoder_sequence"""}
           __SCREAMING_SNAKE_CASE     =      {0: """batch""", 1: """decoder_sequence"""}

      if self.use_past:
           self.fill_with_past_key_values_(__SCREAMING_SNAKE_CASE					,							direction="""inputs"""			)

      return common_inputs


 @property
 def       UpperCAmelCase__		(		self					:       int			)  -> int:


      """simple docstring"""




      return 13









'''simple docstring'''



from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices


UpperCAmelCase :       Optional[int]			   =     logging.get_logger(__name__)

UpperCAmelCase :       str			   =     {
    'facebook/convnextv2-tiny-1k-224': 'https://huggingface.co/facebook/convnextv2-tiny-1k-224/resolve/main/config.json',
}







class 						lowerCAmelCase__   (      a ,					a					):



 """simple docstring"""



 lowerCAmelCase__  					=      "convnextv2"
 def __init__(		self					:       Any					,							__SCREAMING_SNAKE_CASE					:       int=3					,							__SCREAMING_SNAKE_CASE					:       Dict=4					,							__SCREAMING_SNAKE_CASE					:       List[Any]=4					,							__SCREAMING_SNAKE_CASE					:       Optional[int]=None					,							__SCREAMING_SNAKE_CASE					:       Dict=None					,							__SCREAMING_SNAKE_CASE					:       Optional[int]="gelu"					,							__SCREAMING_SNAKE_CASE					:       Union[str, Any]=0.02					,							__SCREAMING_SNAKE_CASE					:       Dict=1E-12					,							__SCREAMING_SNAKE_CASE					:       List[str]=0.0					,							__SCREAMING_SNAKE_CASE					:       Optional[Any]=224					,							__SCREAMING_SNAKE_CASE					:       Tuple=None					,							__SCREAMING_SNAKE_CASE					:       List[str]=None					,							**__SCREAMING_SNAKE_CASE					:       Union[str, Any]					,							)  -> Union[str, Any]:


      """simple docstring"""




      super().__init__(**__SCREAMING_SNAKE_CASE			)

      __SCREAMING_SNAKE_CASE     =      num_channels
      __SCREAMING_SNAKE_CASE     =      patch_size
      __SCREAMING_SNAKE_CASE     =      num_stages
      __SCREAMING_SNAKE_CASE     =      [96, 192, 384, 768] if hidden_sizes is None else hidden_sizes
      __SCREAMING_SNAKE_CASE     =      [3, 3, 9, 3] if depths is None else depths
      __SCREAMING_SNAKE_CASE     =      hidden_act
      __SCREAMING_SNAKE_CASE     =      initializer_range
      __SCREAMING_SNAKE_CASE     =      layer_norm_eps
      __SCREAMING_SNAKE_CASE     =      drop_path_rate
      __SCREAMING_SNAKE_CASE     =      image_size
      __SCREAMING_SNAKE_CASE     =      ["""stem"""] + [f'stage{idx}' for idx in range(1					,							len(self.depths			) + 1			)]
      __SCREAMING_SNAKE_CASE   ,			__SCREAMING_SNAKE_CASE     =      get_aligned_output_features_output_indices(
          out_features=__SCREAMING_SNAKE_CASE					,							out_indices=__SCREAMING_SNAKE_CASE					,							stage_names=self.stage_names			)






