





'''simple docstring'''






from collections import OrderedDict
from typing import Any, Mapping, Optional

from ... import PreTrainedTokenizer
from ...configuration_utils import PretrainedConfig
from ...file_utils import TensorType, is_torch_available
from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeqaSeqConfigWithPast
from ...onnx.utils import compute_effective_axis_dimension
from ...utils import logging


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

__lowerCamelCase						: int		=   {
    'facebook/blenderbot_small-90M': 'https://huggingface.co/facebook/blenderbot_small-90M/resolve/main/config.json',
    # See all BlenderbotSmall models at https://huggingface.co/models?filter=blenderbot_small
}







class 		UpperCAmelCase   (				lowercase_):


  """simple docstring"""







  lowerCAmelCase_					=				"""blenderbot-small"""
  lowerCAmelCase_					=				["""past_key_values"""]
  lowerCAmelCase_					=				{"""num_attention_heads""": """encoder_attention_heads""", """hidden_size""": """d_model"""}


  def __init__(				self    :					str							,	UpperCamelCase__    :					Any=5_0265							,	UpperCamelCase__    :					str=512							,	UpperCamelCase__    :					Optional[Any]=8							,	UpperCamelCase__    :					Optional[int]=2048							,	UpperCamelCase__    :					Union[str, Any]=16							,	UpperCamelCase__    :					Optional[int]=8							,	UpperCamelCase__    :					Optional[Any]=2048							,	UpperCamelCase__    :					int=16							,	UpperCamelCase__    :					Dict=0.0							,	UpperCamelCase__    :					Optional[Any]=0.0							,	UpperCamelCase__    :					Optional[Any]=True							,	UpperCamelCase__    :					Optional[int]=True							,	UpperCamelCase__    :					int="gelu"							,	UpperCamelCase__    :					str=512							,	UpperCamelCase__    :					str=0.1							,	UpperCamelCase__    :					int=0.0							,	UpperCamelCase__    :					List[str]=0.0							,	UpperCamelCase__    :					int=0.02							,	UpperCamelCase__    :					Optional[int]=1							,	UpperCamelCase__    :					List[str]=False							,	UpperCamelCase__    :					Union[str, Any]=0							,	UpperCamelCase__    :					int=1							,	UpperCamelCase__    :					Dict=2							,	UpperCamelCase__    :					int=2							,	**UpperCamelCase__    :					str							,	)     ->						List[str]:
    _UpperCamelCase       			=vocab_size
    _UpperCamelCase       			=max_position_embeddings
    _UpperCamelCase       			=d_model
    _UpperCamelCase       			=encoder_ffn_dim
    _UpperCamelCase       			=encoder_layers
    _UpperCamelCase       			=encoder_attention_heads
    _UpperCamelCase       			=decoder_ffn_dim
    _UpperCamelCase       			=decoder_layers
    _UpperCamelCase       			=decoder_attention_heads
    _UpperCamelCase       			=dropout
    _UpperCamelCase       			=attention_dropout
    _UpperCamelCase       			=activation_dropout
    _UpperCamelCase       			=activation_function
    _UpperCamelCase       			=init_std
    _UpperCamelCase       			=encoder_layerdrop
    _UpperCamelCase       			=decoder_layerdrop
    _UpperCamelCase       			=use_cache
    _UpperCamelCase       			=encoder_layers
    _UpperCamelCase       			=scale_embedding  # scale factor will be sqrt(d_model) if True

    super().__init__(
        pad_token_id=UpperCamelCase__							,	bos_token_id=UpperCamelCase__							,	eos_token_id=UpperCamelCase__							,	is_encoder_decoder=UpperCamelCase__							,	decoder_start_token_id=UpperCamelCase__							,	forced_eos_token_id=UpperCamelCase__							,	**UpperCamelCase__							,	)







class 		UpperCAmelCase   (				lowercase_):


  """simple docstring"""







  @property
  def   UpperCamelCase__      (				self    :					Optional[int]  )     ->						Mapping[str, Mapping[int, str]]:
    if self.task in ["default", "seq2seq-lm"]:
      _UpperCamelCase       			=OrderedDict(
          [
              ('''input_ids''', {0: '''batch''', 1: '''encoder_sequence'''}),
              ('''attention_mask''', {0: '''batch''', 1: '''encoder_sequence'''}),
          ]  )

      if self.use_past:
        _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'''  )
    elif self.task == "causal-lm":
      # TODO: figure this case out.
      _UpperCamelCase       			=OrderedDict(
          [
              ('''input_ids''', {0: '''batch''', 1: '''encoder_sequence'''}),
              ('''attention_mask''', {0: '''batch''', 1: '''encoder_sequence'''}),
          ]  )
      if self.use_past:
        _UpperCamelCase			,     _UpperCamelCase       			=self.num_layers
        for i in range(UpperCamelCase__  ):
          _UpperCamelCase       			={0: '''batch''', 2: '''past_sequence + sequence'''}
          _UpperCamelCase       			={0: '''batch''', 2: '''past_sequence + sequence'''}
    else:
      _UpperCamelCase       			=OrderedDict(
          [
              ('''input_ids''', {0: '''batch''', 1: '''encoder_sequence'''}),
              ('''attention_mask''', {0: '''batch''', 1: '''encoder_sequence'''}),
              ('''decoder_input_ids''', {0: '''batch''', 1: '''decoder_sequence'''}),
              ('''decoder_attention_mask''', {0: '''batch''', 1: '''decoder_sequence'''}),
          ]  )

    return common_inputs


  @property
  def   UpperCamelCase__      (				self    :					Any  )     ->						Mapping[str, Mapping[int, str]]:
    if self.task in ["default", "seq2seq-lm"]:
      _UpperCamelCase       			=super().outputs
    else:
      _UpperCamelCase       			=super(UpperCamelCase__							,	self  ).outputs
      if self.use_past:
        _UpperCamelCase			,     _UpperCamelCase       			=self.num_layers
        for i in range(UpperCamelCase__  ):
          _UpperCamelCase       			={0: '''batch''', 2: '''past_sequence + sequence'''}
          _UpperCamelCase       			={0: '''batch''', 2: '''past_sequence + sequence'''}
    return common_outputs


  def   UpperCamelCase__      (				self    :					int							,	UpperCamelCase__    :					PreTrainedTokenizer							,	UpperCamelCase__    :					int = -1							,	UpperCamelCase__    :					int = -1							,	UpperCamelCase__    :					bool = False							,	UpperCamelCase__    :					Optional[TensorType] = None							,	)     ->						Mapping[str, Any]:
    _UpperCamelCase       			=self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
        UpperCamelCase__							,	UpperCamelCase__							,	UpperCamelCase__							,	UpperCamelCase__							,	UpperCamelCase__  )

    # Generate decoder inputs
    _UpperCamelCase       			=seq_length if not self.use_past else 1
    _UpperCamelCase       			=self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
        UpperCamelCase__							,	UpperCamelCase__							,	UpperCamelCase__							,	UpperCamelCase__							,	UpperCamelCase__  )
    _UpperCamelCase       			={F'''decoder_{name}''': tensor for name, tensor in decoder_inputs.items()}
    _UpperCamelCase       			=dict(**UpperCamelCase__							,	**UpperCamelCase__  )

    if self.use_past:
      if not is_torch_available():
        raise ValueError('''Cannot generate dummy past_keys inputs without PyTorch installed.'''  )
      else:
        import torch
      _UpperCamelCase			,     _UpperCamelCase       			=common_inputs['''input_ids'''].shape
      _UpperCamelCase       			=common_inputs['''decoder_input_ids'''].shape[1]
      _UpperCamelCase			,     _UpperCamelCase       			=self.num_attention_heads
      _UpperCamelCase       			=(
          batch,
          num_encoder_attention_heads,
          encoder_seq_length,
          self._config.hidden_size // num_encoder_attention_heads,
      )
      _UpperCamelCase       			=decoder_seq_length + 3
      _UpperCamelCase       			=(
          batch,
          num_decoder_attention_heads,
          decoder_past_length,
          self._config.hidden_size // num_decoder_attention_heads,
      )

      _UpperCamelCase       			=torch.cat(
          [common_inputs['''decoder_attention_mask'''], torch.ones(UpperCamelCase__							,	UpperCamelCase__  )]							,	dim=1  )

      _UpperCamelCase       			=[]
      # If the number of encoder and decoder layers are present in the model configuration, both are considered
      _UpperCamelCase			,     _UpperCamelCase       			=self.num_layers
      _UpperCamelCase       			=min(UpperCamelCase__							,	UpperCamelCase__  )
      _UpperCamelCase       			=max(UpperCamelCase__							,	UpperCamelCase__  ) - min_num_layers
      _UpperCamelCase       			='''encoder''' if num_encoder_layers > num_decoder_layers else '''decoder'''

      for _ in range(UpperCamelCase__  ):
        common_inputs["past_key_values"].append(
            (
                torch.zeros(UpperCamelCase__  ),
                torch.zeros(UpperCamelCase__  ),
                torch.zeros(UpperCamelCase__  ),
                torch.zeros(UpperCamelCase__  ),
            )  )
      # TODO: test this.
      _UpperCamelCase       			=encoder_shape if remaining_side_name == '''encoder''' else decoder_shape
      for _ in range(UpperCamelCase__							,	UpperCamelCase__  ):
        common_inputs["past_key_values"].append((torch.zeros(UpperCamelCase__  ), torch.zeros(UpperCamelCase__  ))  )
    return common_inputs


  def   UpperCamelCase__      (				self    :					Dict							,	UpperCamelCase__    :					PreTrainedTokenizer							,	UpperCamelCase__    :					int = -1							,	UpperCamelCase__    :					int = -1							,	UpperCamelCase__    :					bool = False							,	UpperCamelCase__    :					Optional[TensorType] = None							,	)     ->						Mapping[str, Any]:
    _UpperCamelCase       			=self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
        UpperCamelCase__							,	UpperCamelCase__							,	UpperCamelCase__							,	UpperCamelCase__							,	UpperCamelCase__  )

    if self.use_past:
      if not is_torch_available():
        raise ValueError('''Cannot generate dummy past_keys inputs without PyTorch installed.'''  )
      else:
        import torch
      _UpperCamelCase			,     _UpperCamelCase       			=common_inputs['''input_ids'''].shape
      # Not using the same length for past_key_values
      _UpperCamelCase       			=seqlen + 2
      _UpperCamelCase			,     _UpperCamelCase       			=self.num_layers
      _UpperCamelCase			,     _UpperCamelCase       			=self.num_attention_heads
      _UpperCamelCase       			=(
          batch,
          num_encoder_attention_heads,
          past_key_values_length,
          self._config.hidden_size // num_encoder_attention_heads,
      )

      _UpperCamelCase       			=common_inputs['''attention_mask'''].dtype
      _UpperCamelCase       			=torch.cat(
          [common_inputs['''attention_mask'''], torch.ones(UpperCamelCase__							,	UpperCamelCase__							,	dtype=UpperCamelCase__  )]							,	dim=1  )
      _UpperCamelCase       			=[
          (torch.zeros(UpperCamelCase__  ), torch.zeros(UpperCamelCase__  )) for _ in range(UpperCamelCase__  )
      ]
    return common_inputs


  def   UpperCamelCase__      (				self    :					Optional[Any]							,	UpperCamelCase__    :					PreTrainedTokenizer							,	UpperCamelCase__    :					int = -1							,	UpperCamelCase__    :					int = -1							,	UpperCamelCase__    :					bool = False							,	UpperCamelCase__    :					Optional[TensorType] = None							,	)     ->						Mapping[str, Any]:
    # Copied from OnnxConfig.generate_dummy_inputs
    # Did not use super(OnnxConfigWithPast, self).generate_dummy_inputs for code clarity.
    # If dynamic axis (-1) we forward with a fixed dimension of 2 samples to avoid optimizations made by ONNX
    _UpperCamelCase       			=compute_effective_axis_dimension(
        UpperCamelCase__							,	fixed_dimension=OnnxConfig.default_fixed_batch							,	num_token_to_add=0  )

    # If dynamic axis (-1) we forward with a fixed dimension of 8 tokens to avoid optimizations made by ONNX
    _UpperCamelCase       			=tokenizer.num_special_tokens_to_add(UpperCamelCase__  )
    _UpperCamelCase       			=compute_effective_axis_dimension(
        UpperCamelCase__							,	fixed_dimension=OnnxConfig.default_fixed_sequence							,	num_token_to_add=UpperCamelCase__  )

    # Generate dummy inputs according to compute batch and sequence
    _UpperCamelCase       			=[''' '''.join([tokenizer.unk_token]  ) * seq_length] * batch_size
    _UpperCamelCase       			=dict(tokenizer(UpperCamelCase__							,	return_tensors=UpperCamelCase__  )  )
    return common_inputs


  def   UpperCamelCase__      (				self    :					str							,	UpperCamelCase__    :					PreTrainedTokenizer							,	UpperCamelCase__    :					int = -1							,	UpperCamelCase__    :					int = -1							,	UpperCamelCase__    :					bool = False							,	UpperCamelCase__    :					Optional[TensorType] = None							,	)     ->						Mapping[str, Any]:
    if self.task in ["default", "seq2seq-lm"]:
      _UpperCamelCase       			=self._generate_dummy_inputs_for_default_and_seqaseq_lm(
          UpperCamelCase__							,	batch_size=UpperCamelCase__							,	seq_length=UpperCamelCase__							,	is_pair=UpperCamelCase__							,	framework=UpperCamelCase__  )

    elif self.task == "causal-lm":
      _UpperCamelCase       			=self._generate_dummy_inputs_for_causal_lm(
          UpperCamelCase__							,	batch_size=UpperCamelCase__							,	seq_length=UpperCamelCase__							,	is_pair=UpperCamelCase__							,	framework=UpperCamelCase__  )
    else:
      _UpperCamelCase       			=self._generate_dummy_inputs_for_sequence_classification_and_question_answering(
          UpperCamelCase__							,	batch_size=UpperCamelCase__							,	seq_length=UpperCamelCase__							,	is_pair=UpperCamelCase__							,	framework=UpperCamelCase__  )

    return common_inputs




  def   UpperCamelCase__      (				self    :					Optional[int]							,	UpperCamelCase__    :					Optional[Any]							,	UpperCamelCase__    :					List[Any]							,	UpperCamelCase__    :					List[str]							,	UpperCamelCase__    :					Any  )     ->						Dict:
    if self.task in ["default", "seq2seq-lm"]:
      _UpperCamelCase       			=super()._flatten_past_key_values_(UpperCamelCase__							,	UpperCamelCase__							,	UpperCamelCase__							,	UpperCamelCase__  )
    else:
      _UpperCamelCase       			=super(UpperCamelCase__							,	self  )._flatten_past_key_values_(
          UpperCamelCase__							,	UpperCamelCase__							,	UpperCamelCase__							,	UpperCamelCase__  )













'''simple docstring'''






import argparse
import datetime


def 					_a   (__SCREAMING_SNAKE_CASE   ):


  """simple docstring"""

  _UpperCamelCase       			={
      '''0''': '''Sunday''',
      '''1''': '''Monday''',
      '''2''': '''Tuesday''',
      '''3''': '''Wednesday''',
      '''4''': '''Thursday''',
      '''5''': '''Friday''',
      '''6''': '''Saturday''',
  }

  _UpperCamelCase       			={0: 1, 1: 2, 2: 3, 3: 4, 4: 5, 5: 6, 6: 0}

  # Validate
  if not 0 < len(__SCREAMING_SNAKE_CASE   ) < 11:
    raise ValueError('''Must be 10 characters long'''   )

  # Get month
  _UpperCamelCase       			=int(date_input[0] + date_input[1]   )
  # Validate
  if not 0 < m < 13:
    raise ValueError('''Month must be between 1 - 12'''   )

  _UpperCamelCase       			=date_input[2]
  # Validate
  if sep_a not in ["-", "/"]:
    raise ValueError('''Date separator must be \'-\' or \'/\''''   )

  # Get day
  _UpperCamelCase       			=int(date_input[3] + date_input[4]   )
  # Validate
  if not 0 < d < 32:
    raise ValueError('''Date must be between 1 - 31'''   )

  # Get second separator
  _UpperCamelCase       			=date_input[5]
  # Validate
  if sep_a not in ["-", "/"]:
    raise ValueError('''Date separator must be \'-\' or \'/\''''   )

  # Get year
  _UpperCamelCase       			=int(date_input[6] + date_input[7] + date_input[8] + date_input[9]   )
  # Arbitrary year range
  if not 45 < y < 8500:
    raise ValueError(
        '''Year out of range. There has to be some sort of limit...right?'''   )

  # Get datetime obj for validation
  _UpperCamelCase       			=datetime.date(int(__SCREAMING_SNAKE_CASE   )  ,      int(__SCREAMING_SNAKE_CASE   )  ,      int(__SCREAMING_SNAKE_CASE   )   )

  # Start math
  if m <= 2:
    _UpperCamelCase       			=y - 1
    _UpperCamelCase       			=m + 12
  # maths var
  _UpperCamelCase       			=int(str(__SCREAMING_SNAKE_CASE   )[:2]   )
  _UpperCamelCase       			=int(str(__SCREAMING_SNAKE_CASE   )[2:]   )
  _UpperCamelCase       			=int(2.6 * m - 5.3_9   )
  _UpperCamelCase       			=int(c / 4   )
  _UpperCamelCase       			=int(k / 4   )
  _UpperCamelCase       			=int(d + k   )
  _UpperCamelCase       			=int(t + u + v + x   )
  _UpperCamelCase       			=int(z - (2 * c)   )
  _UpperCamelCase       			=round(w % 7   )
  # End math

  # Validate math
  if f != convert_datetime_days[dt_ck.weekday()]:
    raise AssertionError('''The date was evaluated incorrectly. Contact developer.'''   )

  # Response
  _UpperCamelCase       			=f'''Your date {date_input}, is a {days[str(__SCREAMING_SNAKE_CASE   )]}!'''
  return response


if __name__ == "__main__":
      import doctest

      doctest.testmod()
      __lowerCamelCase						: List[Any]		=   argparse.ArgumentParser(
          description=(
              'Find out what day of the week nearly any date is or was. Enter '
              'date as a string in the mm-dd-yyyy or mm/dd/yyyy format'
          )
      )
      parser.add_argument(
          'date_input', type=str, help='Date as a string (mm-dd-yyyy or mm/dd/yyyy)'
      )
      __lowerCamelCase						: Union[str, Any]		=   parser.parse_args()
      zeller(args.date_input)






