



'''simple docstring'''




from . import __version__

# Backward compatibility imports, to make sure all those objects can be found in file_utils
from .utils import (
    CLOUDFRONT_DISTRIB_PREFIX,
    CONFIG_NAME,
    DISABLE_TELEMETRY,
    DUMMY_INPUTS,
    DUMMY_MASK,
    ENV_VARS_TRUE_AND_AUTO_VALUES,
    ENV_VARS_TRUE_VALUES,
    FEATURE_EXTRACTOR_NAME,
    FLAX_WEIGHTS_NAME,
    HF_MODULES_CACHE,
    HUGGINGFACE_CO_PREFIX,
    HUGGINGFACE_CO_RESOLVE_ENDPOINT,
    MODEL_CARD_NAME,
    MULTIPLE_CHOICE_DUMMY_INPUTS,
    PYTORCH_PRETRAINED_BERT_CACHE,
    PYTORCH_TRANSFORMERS_CACHE,
    S3_BUCKET_PREFIX,
    SENTENCEPIECE_UNDERLINE,
    SPIECE_UNDERLINE,
    TF2_WEIGHTS_NAME,
    TF_WEIGHTS_NAME,
    TORCH_FX_REQUIRED_VERSION,
    TRANSFORMERS_CACHE,
    TRANSFORMERS_DYNAMIC_MODULE_NAME,
    USE_JAX,
    USE_TF,
    USE_TORCH,
    WEIGHTS_INDEX_NAME,
    WEIGHTS_NAME,
    ContextManagers,
    DummyObject,
    EntryNotFoundError,
    ExplicitEnum,
    ModelOutput,
    PaddingStrategy,
    PushToHubMixin,
    RepositoryNotFoundError,
    RevisionNotFoundError,
    TensorType,
    _LazyModule,
    add_code_sample_docstrings,
    add_end_docstrings,
    add_start_docstrings,
    add_start_docstrings_to_model_forward,
    cached_property,
    copy_func,
    default_cache_path,
    define_sagemaker_information,
    get_cached_models,
    get_file_from_repo,
    get_full_repo_name,
    get_torch_version,
    has_file,
    http_user_agent,
    is_apex_available,
    is_bsa_available,
    is_coloredlogs_available,
    is_datasets_available,
    is_detectrona_available,
    is_faiss_available,
    is_flax_available,
    is_ftfy_available,
    is_in_notebook,
    is_ipex_available,
    is_librosa_available,
    is_offline_mode,
    is_onnx_available,
    is_pandas_available,
    is_phonemizer_available,
    is_protobuf_available,
    is_psutil_available,
    is_pyanvml_available,
    is_pyctcdecode_available,
    is_pytesseract_available,
    is_pytorch_quantization_available,
    is_rjieba_available,
    is_sagemaker_dp_enabled,
    is_sagemaker_mp_enabled,
    is_scipy_available,
    is_sentencepiece_available,
    is_seqio_available,
    is_sklearn_available,
    is_soundfile_availble,
    is_spacy_available,
    is_speech_available,
    is_tensor,
    is_tensorflow_probability_available,
    is_tfaonnx_available,
    is_tf_available,
    is_timm_available,
    is_tokenizers_available,
    is_torch_available,
    is_torch_bfaa_available,
    is_torch_cuda_available,
    is_torch_fx_available,
    is_torch_fx_proxy,
    is_torch_mps_available,
    is_torch_tfaa_available,
    is_torch_tpu_available,
    is_torchaudio_available,
    is_training_run_on_sagemaker,
    is_vision_available,
    replace_return_docstrings,
    requires_backends,
    to_numpy,
    to_py_obj,
    torch_only_method,
)




'''simple docstring'''




from typing import Mapping

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


UpperCamelCase__ :			Tuple												=				logging.get_logger(__name__)

UpperCamelCase__ :			List[str]												=				{
    '''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 		_UpperCamelCase						(							lowerCamelCase__					):


			'''simple docstring'''

			_A   :	Union[str, Any]    					=	'''t5'''
			_A   :	Optional[Any]    					=	['''past_key_values''']
			_A   :	Any    					=	{'''hidden_size''': '''d_model''', '''num_attention_heads''': '''num_heads''', '''num_hidden_layers''': '''num_layers'''}

			def __init__(							self  :				Union[str, Any]							,  lowerCAmelCase__  :				List[str]=3_2_1_2_8							,  lowerCAmelCase__  :				Dict=5_1_2							,  lowerCAmelCase__  :				str=6_4							,  lowerCAmelCase__  :				Tuple=2_0_4_8							,  lowerCAmelCase__  :				Optional[Any]=6							,  lowerCAmelCase__  :				Any=None							,  lowerCAmelCase__  :				Any=8							,  lowerCAmelCase__  :				Dict=3_2							,  lowerCAmelCase__  :				Dict=1_2_8							,  lowerCAmelCase__  :				Any=0.1							,  lowerCAmelCase__  :				str=1E-6							,  lowerCAmelCase__  :				str=1.0							,  lowerCAmelCase__  :				Optional[Any]="relu"							,  lowerCAmelCase__  :				List[str]=True							,  lowerCAmelCase__  :				Union[str, Any]=True							,  lowerCAmelCase__  :				Optional[Any]=0							,  lowerCAmelCase__  :				List[Any]=1							,  **lowerCAmelCase__  :				Dict							,  ):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	List[str]					 =	vocab_size
					__SCREAMING_SNAKE_CASE :	str					 =	d_model
					__SCREAMING_SNAKE_CASE :	str					 =	d_kv
					__SCREAMING_SNAKE_CASE :	Optional[Any]					 =	d_ff
					__SCREAMING_SNAKE_CASE :	Optional[Any]					 =	num_layers
					__SCREAMING_SNAKE_CASE :	List[str]					 =	(
					    num_decoder_layers if num_decoder_layers is not None else self.num_layers
					)  # default = symmetry
					__SCREAMING_SNAKE_CASE :	Optional[int]					 =	num_heads
					__SCREAMING_SNAKE_CASE :	Any					 =	relative_attention_num_buckets
					__SCREAMING_SNAKE_CASE :	int					 =	relative_attention_max_distance
					__SCREAMING_SNAKE_CASE :	Optional[int]					 =	dropout_rate
					__SCREAMING_SNAKE_CASE :	Optional[int]					 =	layer_norm_epsilon
					__SCREAMING_SNAKE_CASE :	Optional[int]					 =	initializer_factor
					__SCREAMING_SNAKE_CASE :	Any					 =	feed_forward_proj
					__SCREAMING_SNAKE_CASE :	str					 =	use_cache

					__SCREAMING_SNAKE_CASE :	List[str]					 =	self.feed_forward_proj.split("""-"""		)
					__SCREAMING_SNAKE_CASE :	Tuple					 =	act_info[-1]
					__SCREAMING_SNAKE_CASE :	int					 =	act_info[0] == """gated"""

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

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






class 		_UpperCamelCase						(							lowerCamelCase__					):


			'''simple docstring'''

			@property
			def UpperCamelCase__      (							self  :				Tuple		):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE :	List[Any]					 =	{
					    """input_ids""": {0: """batch""", 1: """encoder_sequence"""},
					    """attention_mask""": {0: """batch""", 1: """encoder_sequence"""},
					}
					if self.use_past:
							__SCREAMING_SNAKE_CASE :	Optional[Any]					 =	"""past_encoder_sequence + sequence"""
							__SCREAMING_SNAKE_CASE :	Optional[Any]					 =	{0: """batch"""}
							__SCREAMING_SNAKE_CASE :	Optional[int]					 =	{0: """batch""", 1: """past_decoder_sequence + sequence"""}
					else:
							__SCREAMING_SNAKE_CASE :	List[Any]					 =	{0: """batch""", 1: """decoder_sequence"""}
							__SCREAMING_SNAKE_CASE :	Optional[Any]					 =	{0: """batch""", 1: """decoder_sequence"""}

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

					return common_inputs



			@property
			def UpperCamelCase__      (							self  :				List[str]		):





					"""simple docstring"""






					return 1_3