
import warnings

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


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

__lowerCAmelCase			:     Optional[int]           =   {
    'xlnet-base-cased': 'https://huggingface.co/xlnet-base-cased/resolve/main/config.json',
    'xlnet-large-cased': 'https://huggingface.co/xlnet-large-cased/resolve/main/config.json',
}




class        UpperCAmelCase_			( _A     ):


  '''simple docstring'''







  a__           =		"""xlnet"""
  a__           =		["""mems"""]
  a__           =		{
      """n_token""": """vocab_size""",  # Backward compatibility
      """hidden_size""": """d_model""",
      """num_attention_heads""": """n_head""",
      """num_hidden_layers""": """n_layer""",
  }
  def __init__( self			: int			,							UpperCamelCase__			: List[str]=3_2000			,							UpperCamelCase__			: Optional[int]=1024			,							UpperCamelCase__			: Union[str, Any]=24			,							UpperCamelCase__			: Optional[int]=16			,							UpperCamelCase__			: List[str]=4096			,							UpperCamelCase__			: Union[str, Any]="gelu"			,							UpperCamelCase__			: Tuple=True			,							UpperCamelCase__			: Tuple="bi"			,							UpperCamelCase__			: List[str]=0.02			,							UpperCamelCase__			: List[str]=1E-12			,							UpperCamelCase__			: Tuple=0.1			,							UpperCamelCase__			: Tuple=512			,							UpperCamelCase__			: str=None			,							UpperCamelCase__			: Dict=True			,							UpperCamelCase__			: Optional[int]=False			,							UpperCamelCase__			: List[str]=False			,							UpperCamelCase__			: Any=-1			,							UpperCamelCase__			: Dict=False			,							UpperCamelCase__			: int="last"			,							UpperCamelCase__			: Optional[Any]=True			,							UpperCamelCase__			: List[Any]="tanh"			,							UpperCamelCase__			: Tuple=0.1			,							UpperCamelCase__			: List[str]=5			,							UpperCamelCase__			: Tuple=5			,							UpperCamelCase__			: str=5			,							UpperCamelCase__			: Optional[int]=1			,							UpperCamelCase__			: List[str]=2			,							**UpperCamelCase__			: List[Any]			,							)			->	Any:







    """simple docstring"""






    __magic_name__				     =       vocab_size
    __magic_name__				     =       d_model
    __magic_name__				     =       n_layer
    __magic_name__				     =       n_head
    if d_model % n_head != 0:
      raise ValueError(F'''\'d_model % n_head\' ({d_model % n_head}) should be equal to 0'''    )
    if "d_head" in kwargs:
      if kwargs["d_head"] != d_model // n_head:
        raise ValueError(
            F'''`d_head` ({kwargs['d_head']}) should be equal to `d_model // n_head` ({d_model // n_head})'''    )
    __magic_name__				     =       d_model // n_head
    __magic_name__				     =       ff_activation
    __magic_name__				     =       d_inner
    __magic_name__				     =       untie_r
    __magic_name__				     =       attn_type

    __magic_name__				     =       initializer_range
    __magic_name__				     =       layer_norm_eps

    __magic_name__				     =       dropout
    __magic_name__				     =       mem_len
    __magic_name__				     =       reuse_len
    __magic_name__				     =       bi_data
    __magic_name__				     =       clamp_len
    __magic_name__				     =       same_length

    __magic_name__				     =       summary_type
    __magic_name__				     =       summary_use_proj
    __magic_name__				     =       summary_activation
    __magic_name__				     =       summary_last_dropout
    __magic_name__				     =       start_n_top
    __magic_name__				     =       end_n_top

    __magic_name__				     =       bos_token_id
    __magic_name__				     =       pad_token_id
    __magic_name__				     =       eos_token_id

    if "use_cache" in kwargs:
      warnings.warn(
          """The `use_cache` argument is deprecated and will be removed in a future version, use `use_mems_eval`"""
          """ instead."""			,							UpperCamelCase__			,							)
      __magic_name__				     =       kwargs["""use_cache"""]

    __magic_name__				     =       use_mems_eval
    __magic_name__				     =       use_mems_train
    super().__init__(pad_token_id=UpperCamelCase__			,							bos_token_id=UpperCamelCase__			,							eos_token_id=UpperCamelCase__			,							**UpperCamelCase__    )
  @property
  def 							_lowercase							( self			: int    )			->	Tuple:







    """simple docstring"""






    logger.info(F'''The model {self.model_type} is one of the few models that has no sequence length limit.'''    )
    return -1





  @max_position_embeddings.setter
  def 							_lowercase							( self			: Any			,							UpperCamelCase__			: Optional[Any]    )			->	Dict:







    """simple docstring"""






    raise NotImplementedError(
        F'''The model {self.model_type} is one of the few models that has no sequence length limit.'''    )



import re
import string

import numpy as np

import datasets


__lowerCAmelCase			:     Optional[int]           =   '\nReturns the rate at which the input predicted strings exactly match their references, ignoring any strings input as part of the regexes_to_ignore list.\n'

__lowerCAmelCase			:     Optional[int]           =   '\nArgs:\n    predictions: List of predicted texts.\n    references: List of reference texts.\n    regexes_to_ignore: List, defaults to None. Regex expressions of characters to\n        ignore when calculating the exact matches. Note: these regexes are removed\n        from the input data before the changes based on the options below (e.g. ignore_case,\n        ignore_punctuation, ignore_numbers) are applied.\n    ignore_case: Boolean, defaults to False. If true, turns everything\n        to lowercase so that capitalization differences are ignored.\n    ignore_punctuation: Boolean, defaults to False. If true, removes all punctuation before\n        comparing predictions and references.\n    ignore_numbers: Boolean, defaults to False. If true, removes all punctuation before\n        comparing predictions and references.\nReturns:\n    exact_match: Dictionary containing exact_match rate. Possible values are between 0.0 and 100.0, inclusive.\nExamples:\n    >>> exact_match = datasets.load_metric("exact_match")\n    >>> refs = ["the cat", "theater", "YELLING", "agent007"]\n    >>> preds = ["cat?", "theater", "yelling", "agent"]\n    >>> results = exact_match.compute(references=refs, predictions=preds)\n    >>> print(round(results["exact_match"], 1))\n    25.0\n\n    >>> exact_match = datasets.load_metric("exact_match")\n    >>> refs = ["the cat", "theater", "YELLING", "agent007"]\n    >>> preds = ["cat?", "theater", "yelling", "agent"]\n    >>> results = exact_match.compute(references=refs, predictions=preds, regexes_to_ignore=["the ", "yell"], ignore_case=True, ignore_punctuation=True)\n    >>> print(round(results["exact_match"], 1))\n    50.0\n\n\n    >>> exact_match = datasets.load_metric("exact_match")\n    >>> refs = ["the cat", "theater", "YELLING", "agent007"]\n    >>> preds = ["cat?", "theater", "yelling", "agent"]\n    >>> results = exact_match.compute(references=refs, predictions=preds, regexes_to_ignore=["the ", "yell", "YELL"], ignore_case=True, ignore_punctuation=True)\n    >>> print(round(results["exact_match"], 1))\n    75.0\n\n    >>> exact_match = datasets.load_metric("exact_match")\n    >>> refs = ["the cat", "theater", "YELLING", "agent007"]\n    >>> preds = ["cat?", "theater", "yelling", "agent"]\n    >>> results = exact_match.compute(references=refs, predictions=preds, regexes_to_ignore=["the ", "yell", "YELL"], ignore_case=True, ignore_punctuation=True, ignore_numbers=True)\n    >>> print(round(results["exact_match"], 1))\n    100.0\n\n    >>> exact_match = datasets.load_metric("exact_match")\n    >>> refs = ["The cat sat on the mat.", "Theaters are great.", "It\'s like comparing oranges and apples."]\n    >>> preds = ["The cat sat on the mat?", "Theaters are great.", "It\'s like comparing apples and oranges."]\n    >>> results = exact_match.compute(references=refs, predictions=preds)\n    >>> print(round(results["exact_match"], 1))\n    33.3\n\n'

__lowerCAmelCase			:     Optional[int]           =   '\n'




@datasets.utils.file_utils.add_start_docstrings(_DESCRIPTION  ,       _KWARGS_DESCRIPTION     )
class        UpperCAmelCase_			( datasets.Metric     ):


  '''simple docstring'''







  def 							_lowercase							( self			: str    )			->	Optional[int]:







    """simple docstring"""






    return datasets.MetricInfo(
        description=_DESCRIPTION			,							citation=_CITATION			,							inputs_description=_KWARGS_DESCRIPTION			,							features=datasets.Features(
            {
                """predictions""": datasets.Value("""string"""			,							id="""sequence"""    ),
                """references""": datasets.Value("""string"""			,							id="""sequence"""    ),
            }    )			,							reference_urls=[]			,							)





  def 							_lowercase							( self			: Optional[int]			,							UpperCamelCase__			: Optional[Any]			,							UpperCamelCase__			: Tuple			,							UpperCamelCase__			: Optional[Any]=None			,							UpperCamelCase__			: Optional[Any]=False			,							UpperCamelCase__			: int=False			,							UpperCamelCase__			: Tuple=False			,							)			->	Dict:







    """simple docstring"""






    if regexes_to_ignore is not None:
      for s in regexes_to_ignore:
        __magic_name__				     =       np.array([re.sub(UpperCamelCase__			,							""""""			,							UpperCamelCase__    ) for x in predictions]    )
        __magic_name__				     =       np.array([re.sub(UpperCamelCase__			,							""""""			,							UpperCamelCase__    ) for x in references]    )
    else:
      __magic_name__				     =       np.asarray(UpperCamelCase__    )
      __magic_name__				     =       np.asarray(UpperCamelCase__    )

    if ignore_case:
      __magic_name__				     =       np.char.lower(UpperCamelCase__    )
      __magic_name__				     =       np.char.lower(UpperCamelCase__    )

    if ignore_punctuation:
      __magic_name__				     =       string.punctuation.maketrans(""""""			,							""""""			,							string.punctuation    )
      __magic_name__				     =       np.char.translate(UpperCamelCase__			,							table=UpperCamelCase__    )
      __magic_name__				     =       np.char.translate(UpperCamelCase__			,							table=UpperCamelCase__    )

    if ignore_numbers:
      __magic_name__				     =       string.digits.maketrans(""""""			,							""""""			,							string.digits    )
      __magic_name__				     =       np.char.translate(UpperCamelCase__			,							table=UpperCamelCase__    )
      __magic_name__				     =       np.char.translate(UpperCamelCase__			,							table=UpperCamelCase__    )

    __magic_name__				     =       predictions == references

    return {"exact_match": np.mean(UpperCamelCase__    ) * 100}

