

"""simple docstring"""





from typing import Mapping

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


_a       =							logging.get_logger(__name__)

_a       =							{
    '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  (	lowercase   ):







 """simple docstring"""







 __UpperCAmelCase	:					Optional[Any]   		=	"t5"
 __UpperCAmelCase	:					Any   		=	["past_key_values"]
 __UpperCAmelCase	:					str   		=	{"hidden_size": "d_model", "num_attention_heads": "num_heads", "num_hidden_layers": "num_layers"}


 def __init__(			self							:			int,					UpperCAmelCase__							:			str=3_2_1_2_8,					UpperCAmelCase__							:			List[Any]=5_1_2,					UpperCAmelCase__							:			List[str]=6_4,					UpperCAmelCase__							:			List[str]=2_0_4_8,					UpperCAmelCase__							:			Tuple=6,					UpperCAmelCase__							:			Dict=None,					UpperCAmelCase__							:			Tuple=8,					UpperCAmelCase__							:			List[Any]=3_2,					UpperCAmelCase__							:			Optional[Any]=1_2_8,					UpperCAmelCase__							:			str=0.1,					UpperCAmelCase__							:			int=1E-6,					UpperCAmelCase__							:			Tuple=1.0,					UpperCAmelCase__							:			Dict="relu",					UpperCAmelCase__							:			Optional[Any]=True,					UpperCAmelCase__							:			List[str]=True,					UpperCAmelCase__							:			Optional[Any]=0,					UpperCAmelCase__							:			Any=1,					**UpperCAmelCase__							:			Any,					):
    __lowercase								=						vocab_size
    __lowercase								=						d_model
    __lowercase								=						d_kv
    __lowercase								=						d_ff
    __lowercase								=						num_layers
    __lowercase								=						(
        num_decoder_layers if num_decoder_layers is not None else self.num_layers
    )  # default = symmetry
    __lowercase								=						num_heads
    __lowercase								=						relative_attention_num_buckets
    __lowercase								=						relative_attention_max_distance
    __lowercase								=						dropout_rate
    __lowercase								=						layer_norm_epsilon
    __lowercase								=						initializer_factor
    __lowercase								=						feed_forward_proj
    __lowercase								=						use_cache

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

    if len(UpperCAmelCase__	) > 1 and act_info[0] != "gated" or len(UpperCAmelCase__	) > 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":
       __lowercase								=						'gelu_new'

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







class 					_lowerCAmelCase  (	lowercase   ):







 """simple docstring"""







 @property
 def 					_lowercase (			self							:			Tuple	):
    __lowercase								=						{
        'input_ids': {0: 'batch', 1: 'encoder_sequence'},
        'attention_mask': {0: 'batch', 1: 'encoder_sequence'},
    }
    if self.use_past:
       __lowercase								=						'past_encoder_sequence + sequence'
       __lowercase								=						{0: 'batch'}
       __lowercase								=						{0: 'batch', 1: 'past_decoder_sequence + sequence'}
    else:
       __lowercase								=						{0: 'batch', 1: 'decoder_sequence'}
       __lowercase								=						{0: 'batch', 1: 'decoder_sequence'}

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

    return common_inputs



 @property
 def 					_lowercase (			self							:			Tuple	):
    return 1_3










"""simple docstring"""






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


lowercase__     						=						logging.get_logger(__name__)

lowercase__     						=						{"""ctrl""": """https://huggingface.co/ctrl/resolve/main/config.json"""}






class lowerCAmelCase__	(     lowercase						):






			'''simple docstring'''



			lowerCamelCase__      =			"""ctrl"""
			lowerCamelCase__      =			["""past_key_values"""]
			lowerCamelCase__      =			{
			    """max_position_embeddings""": """n_positions""",
			    """hidden_size""": """n_embd""",
			    """num_attention_heads""": """n_head""",
			    """num_hidden_layers""": """n_layer""",
			}
			def __init__(  self  ,      lowercase=246534  ,      lowercase=256  ,      lowercase=1280  ,      lowercase=8192  ,      lowercase=48  ,      lowercase=16  ,      lowercase=0.1  ,      lowercase=0.1  ,      lowercase=1E-6  ,      lowercase=0.02  ,      lowercase=True  ,      **lowercase  ,      ):
							_lowerCamelCase     :			Any    =    vocab_size
							_lowerCamelCase     :			Dict    =    n_positions
							_lowerCamelCase     :			Optional[int]    =    n_embd
							_lowerCamelCase     :			str    =    n_layer
							_lowerCamelCase     :			Union[str, Any]    =    n_head
							_lowerCamelCase     :			Any    =    dff
							_lowerCamelCase     :			int    =    resid_pdrop
							_lowerCamelCase     :			Dict    =    embd_pdrop
							_lowerCamelCase     :			Union[str, Any]    =    layer_norm_epsilon
							_lowerCamelCase     :			Tuple    =    initializer_range

							_lowerCamelCase     :			str    =    use_cache

							super().__init__(**lowercase  )