


'''simple docstring'''




from typing import Mapping

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


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



class 			lowerCAmelCase					(					A_				):
	_lowerCamelCase :       List[str]         =			'''mt5'''
	_lowerCamelCase :       Optional[int]         =			['''past_key_values''']



	def __init__(       self			,       snake_case__=25_0112			,       snake_case__=512			,       snake_case__=64			,       snake_case__=1024			,       snake_case__=8			,       snake_case__=None			,       snake_case__=6			,       snake_case__=32			,       snake_case__=128			,       snake_case__=0.1			,       snake_case__=1e-6			,       snake_case__=1.0			,       snake_case__="gated-gelu"			,       snake_case__=True			,       snake_case__=True			,       snake_case__="T5Tokenizer"			,       snake_case__=False			,       snake_case__=0			,       snake_case__=1			,       snake_case__=0			,       **snake_case__			,       ):
		super().__init__(
		    is_encoder_decoder=lowerCamelCase_			,       tokenizer_class=lowerCamelCase_			,       tie_word_embeddings=lowerCamelCase_			,       pad_token_id=lowerCamelCase_			,       eos_token_id=lowerCamelCase_			,       decoder_start_token_id=lowerCamelCase_			,       **lowerCamelCase_			,       )
		lowerCAmelCase       :     int   				=			vocab_size
		lowerCAmelCase       :     Tuple   				=			d_model
		lowerCAmelCase       :     Tuple   				=			d_kv
		lowerCAmelCase       :     int   				=			d_ff
		lowerCAmelCase       :     List[str]   				=			num_layers
		lowerCAmelCase       :     Any   				=			(
		    num_decoder_layers if num_decoder_layers is not None else self.num_layers
		)  # default = symmetry
		lowerCAmelCase       :     List[str]   				=			num_heads
		lowerCAmelCase       :     List[str]   				=			relative_attention_num_buckets
		lowerCAmelCase       :     Optional[int]   				=			relative_attention_max_distance
		lowerCAmelCase       :     List[str]   				=			dropout_rate
		lowerCAmelCase       :     Optional[int]   				=			layer_norm_epsilon
		lowerCAmelCase       :     Union[str, Any]   				=			initializer_factor
		lowerCAmelCase       :     Tuple   				=			feed_forward_proj
		lowerCAmelCase       :     Dict   				=			use_cache

		lowerCAmelCase       :     Optional[int]   				=			self.feed_forward_proj.split('-'     )
		lowerCAmelCase       :     Optional[int]   				=			act_info[-1]
		lowerCAmelCase       :     Any   				=			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":
			lowerCAmelCase       :     List[Any]   				=			'gelu_new'



	@property
	def 					lowercase  (       self     ):
		return self.d_model



	@property
	def 					lowercase  (       self     ):
		return self.num_heads



	@property
	def 					lowercase  (       self     ):
		return self.num_layers



class 			lowerCAmelCase					(					A_				):



	@property
	# Copied from transformers.models.t5.configuration_t5.T5OnnxConfig.inputs
	def 					lowercase  (       self     ):
		lowerCAmelCase       :     Union[str, Any]   				=			{
		    'input_ids': {0: 'batch', 1: 'encoder_sequence'},
		    'attention_mask': {0: 'batch', 1: 'encoder_sequence'},
		}
		if self.use_past:
			lowerCAmelCase       :     int   				=			'past_encoder_sequence + sequence'
			lowerCAmelCase       :     List[str]   				=			{0: 'batch'}
			lowerCAmelCase       :     Any   				=			{0: 'batch', 1: 'past_decoder_sequence + sequence'}
		else:
			lowerCAmelCase       :     int   				=			{0: 'batch', 1: 'decoder_sequence'}
			lowerCAmelCase       :     Optional[Any]   				=			{0: 'batch', 1: 'decoder_sequence'}

		if self.use_past:
			self.fill_with_past_key_values_(lowerCamelCase_			,       direction='inputs'     )

		return common_inputs



	@property
	# Copied from transformers.models.t5.configuration_t5.T5OnnxConfig.default_onnx_opset
	def 					lowercase  (       self     ):
		return 13



	@property
	def 					lowercase  (       self     ):
		return 5e-4

"""simple docstring"""


from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available


__A       			=      {
    """configuration_realm""": ["""REALM_PRETRAINED_CONFIG_ARCHIVE_MAP""", """RealmConfig"""],
    """tokenization_realm""": ["""RealmTokenizer"""],
}

try:
 if not is_tokenizers_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 __A       			=      ["""RealmTokenizerFast"""]

try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 __A       			=      [
     """REALM_PRETRAINED_MODEL_ARCHIVE_LIST""",
     """RealmEmbedder""",
     """RealmForOpenQA""",
     """RealmKnowledgeAugEncoder""",
     """RealmPreTrainedModel""",
     """RealmReader""",
     """RealmScorer""",
     """load_tf_weights_in_realm""",
 ]
 __A       			=      ["""RealmRetriever"""]


if TYPE_CHECKING:
 from .configuration_realm import REALM_PRETRAINED_CONFIG_ARCHIVE_MAP, RealmConfig
 from .tokenization_realm import RealmTokenizer

 try:
  if not is_tokenizers_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .tokenization_realm import RealmTokenizerFast

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_realm import (
      REALM_PRETRAINED_MODEL_ARCHIVE_LIST,
      RealmEmbedder,
      RealmForOpenQA,
      RealmKnowledgeAugEncoder,
      RealmPreTrainedModel,
      RealmReader,
      RealmScorer,
      load_tf_weights_in_realm,
  )
  from .retrieval_realm import RealmRetriever


else:
 import sys

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