






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


lowercase						:      int									= logging.get_logger(__name__)

lowercase						:      Union[str, Any]									= {
    'edbeeching/decision-transformer-gym-hopper-medium': (
        'https://huggingface.co/edbeeching/decision-transformer-gym-hopper-medium/resolve/main/config.json'
    ),
    # See all DecisionTransformer models at https://huggingface.co/models?filter=decision_transformer
}




class 				lowerCamelCase__							(       __lowercase):




	'''simple docstring'''




	_A			=  'decision_transformer'
	_A			=  ['past_key_values']
	_A			=  {
	    'max_position_embeddings': 'n_positions',
	    'num_attention_heads': 'n_head',
	    'num_hidden_layers': 'n_layer',
	}







	def __init__(      self	:Optional[int]  ,     a	:Tuple=1_7  ,     a	:Optional[Any]=4  ,     a	:Optional[int]=1_2_8  ,     a	:Union[str, Any]=4_0_9_6  ,     a	:Union[str, Any]=True  ,     a	:List[Any]=1  ,     a	:Optional[Any]=1_0_2_4  ,     a	:Any=3  ,     a	:List[str]=1  ,     a	:List[Any]=None  ,     a	:Optional[int]="relu"  ,     a	:str=0.1  ,     a	:int=0.1  ,     a	:Any=0.1  ,     a	:Union[str, Any]=1E-5  ,     a	:str=0.02  ,     a	:List[str]=True  ,     a	:str=True  ,     a	:Dict=5_0_2_5_6  ,     a	:Optional[Any]=5_0_2_5_6  ,     a	:List[Any]=False  ,     a	:List[str]=False  ,     **a	:Dict  ,     )	->				List[Any]:
								__UpperCamelCase			:     int         =      state_dim
								__UpperCamelCase			:     str         =      act_dim
								__UpperCamelCase			:     str         =      hidden_size
								__UpperCamelCase			:     List[str]         =      max_ep_len
								__UpperCamelCase			:     List[str]         =      action_tanh
								__UpperCamelCase			:     Optional[Any]         =      vocab_size
								__UpperCamelCase			:     Any         =      n_positions
								__UpperCamelCase			:     List[str]         =      n_layer
								__UpperCamelCase			:     Tuple         =      n_head
								__UpperCamelCase			:     int         =      n_inner
								__UpperCamelCase			:     Any         =      activation_function
								__UpperCamelCase			:     Union[str, Any]         =      resid_pdrop
								__UpperCamelCase			:     Optional[int]         =      embd_pdrop
								__UpperCamelCase			:     Optional[int]         =      attn_pdrop
								__UpperCamelCase			:     Tuple         =      layer_norm_epsilon
								__UpperCamelCase			:     int         =      initializer_range
								__UpperCamelCase			:     int         =      scale_attn_weights
								__UpperCamelCase			:     str         =      use_cache
								__UpperCamelCase			:     int         =      scale_attn_by_inverse_layer_idx
								__UpperCamelCase			:     Any         =      reorder_and_upcast_attn

								__UpperCamelCase			:     Optional[Any]         =      bos_token_id
								__UpperCamelCase			:     Union[str, Any]         =      eos_token_id

								super().__init__(bos_token_id=a  ,     eos_token_id=a  ,     **a		)

import re
import string

import numpy as np

import datasets


lowercase						:      List[str]									= '\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'

lowercase						:      List[str]									= '\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'

lowercase						:      List[str]									= '\n'




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




	'''simple docstring'''




	def      _lowerCamelCase       (      self	:Dict		)	->				Optional[Any]:
								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      _lowerCamelCase       (      self	:int  ,     a	:Optional[Any]  ,     a	:Dict  ,     a	:Optional[int]=None  ,     a	:int=False  ,     a	:Tuple=False  ,     a	:Optional[int]=False  ,     )	->				Any:
								if regexes_to_ignore is not None:
															for s in regexes_to_ignore:
																						__UpperCamelCase			:     List[Any]         =      np.array([re.sub(a  ,     ""  ,     a		) for x in predictions]		)
																						__UpperCamelCase			:     Optional[Any]         =      np.array([re.sub(a  ,     ""  ,     a		) for x in references]		)
								else:
															__UpperCamelCase			:     Optional[int]         =      np.asarray(a		)
															__UpperCamelCase			:     List[str]         =      np.asarray(a		)

								if ignore_case:
															__UpperCamelCase			:     Optional[int]         =      np.char.lower(a		)
															__UpperCamelCase			:     str         =      np.char.lower(a		)

								if ignore_punctuation:
															__UpperCamelCase			:     Tuple         =      string.punctuation.maketrans(""  ,     ""  ,     string.punctuation		)
															__UpperCamelCase			:     int         =      np.char.translate(a  ,     table=a		)
															__UpperCamelCase			:     str         =      np.char.translate(a  ,     table=a		)

								if ignore_numbers:
															__UpperCamelCase			:     List[str]         =      string.digits.maketrans(""  ,     ""  ,     string.digits		)
															__UpperCamelCase			:     Tuple         =      np.char.translate(a  ,     table=a		)
															__UpperCamelCase			:     Union[str, Any]         =      np.char.translate(a  ,     table=a		)

								__UpperCamelCase			:     List[Any]         =      predictions == references

								return {"exact_match": np.mean(a		) * 1_0_0}