





'''simple docstring'''






from typing import Mapping

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


__lowerCamelCase						: List[Any]		=   logging.get_logger(__name__)

__lowerCamelCase						: Optional[int]		=   {
    'google/umt5-small': 'https://huggingface.co/google/umt5-small/resolve/main/config.json',
    # See all umt5 models at https://huggingface.co/models?filter=umt5
}







class 		UpperCAmelCase   (				lowercase_):


  """simple docstring"""







  lowerCAmelCase_					=				"""umt5"""
  lowerCAmelCase_					=				["""past_key_values"""]


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

    _UpperCamelCase       			=self.feed_forward_proj.split('''-'''  )
    _UpperCamelCase       			=act_info[-1]
    _UpperCamelCase       			=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\''''  )

    if feed_forward_proj == "gated-gelu":
      _UpperCamelCase       			='''gelu_new'''


  @property
  def   UpperCamelCase__      (				self    :					Dict  )     ->						Dict:
    return self.d_model


  @property
  def   UpperCamelCase__      (				self    :					Optional[int]  )     ->						List[str]:
    return self.num_heads




  @property
  def   UpperCamelCase__      (				self    :					Dict  )     ->						int:
    return self.num_layers







class 		UpperCAmelCase   (				lowercase_):


  """simple docstring"""







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

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

    return common_inputs


  @property
  # Copied from transformers.models.t5.configuration_t5.T5OnnxConfig.default_onnx_opset
  def   UpperCamelCase__      (				self    :					Tuple  )     ->						int:
    return 13




  @property
  def   UpperCamelCase__      (				self    :					Optional[Any]  )     ->						float:
    return 5E-4













'''simple docstring'''






from collections.abc import Generator
from math import sin


def 					_a   (__SCREAMING_SNAKE_CASE   ):


  """simple docstring"""

  if len(__SCREAMING_SNAKE_CASE   ) != 32:
    raise ValueError('''Input must be of length 32'''   )

  _UpperCamelCase       			=b''''''
  for i in [3, 2, 1, 0]:
    little_endian += string_aa[8 * i : 8 * i + 8]
  return little_endian


def 					_a   (__SCREAMING_SNAKE_CASE   ):


  """simple docstring"""

  if i < 0:
    raise ValueError('''Input must be non-negative'''   )

  _UpperCamelCase       			=format(__SCREAMING_SNAKE_CASE  ,      '''08x'''   )[-8:]
  _UpperCamelCase       			=b''''''
  for i in [3, 2, 1, 0]:
    little_endian_hex += hex_rep[2 * i : 2 * i + 2].encode('''utf-8'''   )
  return little_endian_hex


def 					_a   (__SCREAMING_SNAKE_CASE   ):


  """simple docstring"""

  _UpperCamelCase       			=b''''''
  for char in message:
    bit_string += format(__SCREAMING_SNAKE_CASE  ,      '''08b'''   ).encode('''utf-8'''   )
  _UpperCamelCase       			=format(len(__SCREAMING_SNAKE_CASE   )  ,      '''064b'''   ).encode('''utf-8'''   )

  # Pad bit_string to a multiple of 512 chars
  bit_string += b"1"
  while len(__SCREAMING_SNAKE_CASE   ) % 512 != 448:
    bit_string += b"0"
  bit_string += to_little_endian(start_len[32:]   ) + to_little_endian(start_len[:32]   )

  return bit_string


def 					_a   (__SCREAMING_SNAKE_CASE   ):


  """simple docstring"""

  if len(__SCREAMING_SNAKE_CASE   ) % 512 != 0:
    raise ValueError('''Input must have length that\'s a multiple of 512'''   )

  for pos in range(0  ,      len(__SCREAMING_SNAKE_CASE   )  ,      512   ):
    _UpperCamelCase       			=bit_string[pos : pos + 512]
    _UpperCamelCase       			=[]
    for i in range(0  ,      512  ,      32   ):
      block_words.append(int(to_little_endian(block[i : i + 32]   )  ,      2   )   )
    yield block_words


def 					_a   (__SCREAMING_SNAKE_CASE   ):


  """simple docstring"""

  if i < 0:
    raise ValueError('''Input must be non-negative'''   )

  _UpperCamelCase       			=format(__SCREAMING_SNAKE_CASE  ,      '''032b'''   )
  _UpperCamelCase       			=''''''
  for c in i_str:
    new_str += "1" if c == "0" else "0"
  return int(__SCREAMING_SNAKE_CASE  ,      2   )


def 					_a   (__SCREAMING_SNAKE_CASE  ,      __SCREAMING_SNAKE_CASE   ):


  """simple docstring"""

  return (a + b) % 2**32


def 					_a   (__SCREAMING_SNAKE_CASE  ,      __SCREAMING_SNAKE_CASE   ):


  """simple docstring"""

  if i < 0:
    raise ValueError('''Input must be non-negative'''   )
  if shift < 0:
    raise ValueError('''Shift must be non-negative'''   )
  return ((i << shift) ^ (i >> (32 - shift))) % 2**32


def 					_a   (__SCREAMING_SNAKE_CASE   ):


  """simple docstring"""

  _UpperCamelCase       			=preprocess(__SCREAMING_SNAKE_CASE   )

  _UpperCamelCase       			=[int(2**32 * abs(sin(i + 1   )   )   ) for i in range(64   )]

  # Starting states
  _UpperCamelCase       			=0X6745_2301
  _UpperCamelCase       			=0Xefcd_ab89
  _UpperCamelCase       			=0X98ba_dcfe
  _UpperCamelCase       			=0X1032_5476

  _UpperCamelCase       			=[
      7,
      12,
      17,
      22,
      7,
      12,
      17,
      22,
      7,
      12,
      17,
      22,
      7,
      12,
      17,
      22,
      5,
      9,
      14,
      20,
      5,
      9,
      14,
      20,
      5,
      9,
      14,
      20,
      5,
      9,
      14,
      20,
      4,
      11,
      16,
      23,
      4,
      11,
      16,
      23,
      4,
      11,
      16,
      23,
      4,
      11,
      16,
      23,
      6,
      10,
      15,
      21,
      6,
      10,
      15,
      21,
      6,
      10,
      15,
      21,
      6,
      10,
      15,
      21,
  ]

  # Process bit string in chunks, each with 16 32-char words
  for block_words in get_block_words(__SCREAMING_SNAKE_CASE   ):
    _UpperCamelCase       			=aa
    _UpperCamelCase       			=ba
    _UpperCamelCase       			=ca
    _UpperCamelCase       			=da

    # Hash current chunk
    for i in range(64   ):
      if i <= 15:
        # f = (b & c) | (not_32(b) & d)     # Alternate definition for f
        _UpperCamelCase       			=d ^ (b & (c ^ d))
        _UpperCamelCase       			=i
      elif i <= 31:
        # f = (d & b) | (not_32(d) & c)     # Alternate definition for f
        _UpperCamelCase       			=c ^ (d & (b ^ c))
        _UpperCamelCase       			=(5 * i + 1) % 16
      elif i <= 47:
        _UpperCamelCase       			=b ^ c ^ d
        _UpperCamelCase       			=(3 * i + 5) % 16
      else:
        _UpperCamelCase       			=c ^ (b | not_aa(__SCREAMING_SNAKE_CASE   ))
        _UpperCamelCase       			=(7 * i) % 16
      _UpperCamelCase       			=(f + a + added_consts[i] + block_words[g]) % 2**32
      _UpperCamelCase       			=d
      _UpperCamelCase       			=c
      _UpperCamelCase       			=b
      _UpperCamelCase       			=sum_aa(__SCREAMING_SNAKE_CASE  ,      left_rotate_aa(__SCREAMING_SNAKE_CASE  ,      shift_amounts[i]   )   )

    # Add hashed chunk to running total
    _UpperCamelCase       			=sum_aa(__SCREAMING_SNAKE_CASE  ,      __SCREAMING_SNAKE_CASE   )
    _UpperCamelCase       			=sum_aa(__SCREAMING_SNAKE_CASE  ,      __SCREAMING_SNAKE_CASE   )
    _UpperCamelCase       			=sum_aa(__SCREAMING_SNAKE_CASE  ,      __SCREAMING_SNAKE_CASE   )
    _UpperCamelCase       			=sum_aa(__SCREAMING_SNAKE_CASE  ,      __SCREAMING_SNAKE_CASE   )

  _UpperCamelCase       			=reformat_hex(__SCREAMING_SNAKE_CASE   ) + reformat_hex(__SCREAMING_SNAKE_CASE   ) + reformat_hex(__SCREAMING_SNAKE_CASE   ) + reformat_hex(__SCREAMING_SNAKE_CASE   )
  return digest


if __name__ == "__main__":
      import doctest

      doctest.testmod()






