


'''simple docstring'''



import math
import unittest

from transformers import BioGptConfig, is_torch_available
from transformers.testing_utils import require_torch, slow, torch_device

from ...generation.test_utils import GenerationTesterMixin
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
	import torch

	from transformers import (
	    BioGptForCausalLM,
	    BioGptForSequenceClassification,
	    BioGptForTokenClassification,
	    BioGptModel,
	    BioGptTokenizer,
	)
	from transformers.models.biogpt.modeling_biogpt import BIOGPT_PRETRAINED_MODEL_ARCHIVE_LIST





class 							__UpperCamelCase				:




	def __init__(   self						,				__a						,				__a=13						,				__a=7						,				__a=True						,				__a=True						,				__a=False						,				__a=True						,				__a=99						,				__a=32						,				__a=5						,				__a=4						,				__a=37						,				__a="gelu"						,				__a=0.1						,				__a=0.1						,				__a=512						,				__a=16						,				__a=2						,				__a=0.02						,				__a=3						,				__a=4						,				__a=None						,				):

						'''simple docstring'''





						__a			:       Dict					    =  parent
						__a			:       Tuple					    =  batch_size
						__a			:       str					    =  seq_length
						__a			:       str					    =  is_training
						__a			:       Any					    =  use_input_mask
						__a			:       Dict					    =  use_token_type_ids
						__a			:       List[Any]					    =  use_labels
						__a			:       Tuple					    =  vocab_size
						__a			:       Optional[int]					    =  hidden_size
						__a			:       str					    =  num_hidden_layers
						__a			:       Union[str, Any]					    =  num_attention_heads
						__a			:       int					    =  intermediate_size
						__a			:       Tuple					    =  hidden_act
						__a			:       Union[str, Any]					    =  hidden_dropout_prob
						__a			:       str					    =  attention_probs_dropout_prob
						__a			:       Dict					    =  max_position_embeddings
						__a			:       str					    =  type_vocab_size
						__a			:       List[Any]					    =  type_sequence_label_size
						__a			:       Optional[int]					    =  initializer_range
						__a			:       Tuple					    =  num_labels
						__a			:       Any					    =  num_choices
						__a			:       Any					    =  scope




	def       __UpperCAmelCase							(   self							):

						'''simple docstring'''





						__a			:       Dict					    =  ids_tensor([self.batch_size, self.seq_length]						,				self.vocab_size							)

						__a			:       Tuple					    =  None
						if self.use_input_mask:
											__a			:       Tuple					    =  random_attention_mask([self.batch_size, self.seq_length]							)

						__a			:       Optional[int]					    =  None
						if self.use_token_type_ids:
											__a			:       Optional[int]					    =  ids_tensor([self.batch_size, self.seq_length]						,				self.type_vocab_size							)

						__a			:       Optional[int]					    =  None
						__a			:       Any					    =  None
						__a			:       Dict					    =  None
						if self.use_labels:
											__a			:       Optional[Any]					    =  ids_tensor([self.batch_size]						,				self.type_sequence_label_size							)
											__a			:       Optional[Any]					    =  ids_tensor([self.batch_size, self.seq_length]						,				self.num_labels							)
											__a			:       int					    =  ids_tensor([self.batch_size]						,				self.num_choices							)

						__a			:       Optional[Any]					    =  self.get_config()

						return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels




	def       __UpperCAmelCase							(   self							):

						'''simple docstring'''





						return BioGptConfig(
						    vocab_size=self.vocab_size						,				hidden_size=self.hidden_size						,				num_hidden_layers=self.num_hidden_layers						,				num_attention_heads=self.num_attention_heads						,				intermediate_size=self.intermediate_size						,				hidden_act=self.hidden_act						,				hidden_dropout_prob=self.hidden_dropout_prob						,				attention_probs_dropout_prob=self.attention_probs_dropout_prob						,				max_position_embeddings=self.max_position_embeddings						,				type_vocab_size=self.type_vocab_size						,				is_decoder=__a						,				initializer_range=self.initializer_range						,				)




	def       __UpperCAmelCase							(   self						,				__a						,				__a						,				__a						,				__a						,				__a						,				__a						,				__a							):

						'''simple docstring'''





						__a			:       List[Any]					    =  BioGptModel(config=__a							)
						model.to(__a							)
						model.eval()
						__a			:       int					    =  model(__a						,				attention_mask=__a							)
						__a			:       Dict					    =  model(__a							)
						self.parent.assertEqual(result.last_hidden_state.shape						,				(self.batch_size, self.seq_length, self.hidden_size)							)




	def       __UpperCAmelCase							(   self						,				__a						,				__a						,				__a						,				__a						,				__a						,				__a						,				__a						,				__a						,				__a						,				):

						'''simple docstring'''





						__a			:       str					    =  BioGptForCausalLM(config=__a							)
						model.to(__a							)
						model.eval()
						__a			:       Union[str, Any]					    =  model(__a						,				attention_mask=__a						,				token_type_ids=__a						,				labels=__a							)
						self.parent.assertEqual(result.logits.shape						,				(self.batch_size, self.seq_length, self.vocab_size)							)




	def       __UpperCAmelCase							(   self						,				__a						,				__a						,				__a						,				__a						,				__a						,				*__a							):

						'''simple docstring'''





						__a			:       Optional[Any]					    =  BioGptModel(config=__a							)
						model.to(__a							)
						model.eval()

						# create attention mask
						__a			:       List[str]					    =  torch.ones(input_ids.shape						,				dtype=torch.long						,				device=__a							)
						__a			:       Tuple					    =  self.seq_length // 2
						__a			:       Union[str, Any]					    =  0

						# first forward pass
						__a    ,				__a			:       Union[str, Any]					    =  model(__a						,				attention_mask=__a							).to_tuple()

						# create hypothetical next token and extent to next_input_ids
						__a			:       Optional[int]					    =  ids_tensor((self.batch_size, 1)						,				config.vocab_size							)

						# change a random masked slice from input_ids
						__a			:       int					    =  ids_tensor((1,)						,				__a							).item() + 1
						__a			:       str					    =  ids_tensor((self.batch_size, 1)						,				config.vocab_size							).squeeze(-1							)
						__a			:       Tuple					    =  random_other_next_tokens

						# append to next input_ids and attn_mask
						__a			:       List[Any]					    =  torch.cat([input_ids, next_tokens]						,				dim=-1							)
						__a			:       Dict					    =  torch.cat(
						    [attn_mask, torch.ones((attn_mask.shape[0], 1)						,				dtype=torch.long						,				device=__a							)]						,				dim=1						,				)

						# get two different outputs
						__a			:       Union[str, Any]					    =  model(__a						,				attention_mask=__a							)['last_hidden_state']
						__a			:       List[Any]					    =  model(__a						,				past_key_values=__a						,				attention_mask=__a							)['last_hidden_state']

						# select random slice
						__a			:       int					    =  ids_tensor((1,)						,				output_from_past.shape[-1]							).item()
						__a			:       List[str]					    =  output_from_no_past[:, -1, random_slice_idx].detach()
						__a			:       Union[str, Any]					    =  output_from_past[:, 0, random_slice_idx].detach()

						# test that outputs are equal for slice
						self.parent.assertTrue(torch.allclose(__a						,				__a						,				atol=1E-3							)							)




	def       __UpperCAmelCase							(   self						,				__a						,				__a						,				__a						,				__a						,				__a						,				*__a							):

						'''simple docstring'''





						__a			:       Optional[int]					    =  BioGptModel(config=__a							).to(__a							).eval()

						__a			:       str					    =  torch.ones(input_ids.shape						,				dtype=torch.long						,				device=__a							)

						# first forward pass
						__a			:       List[Any]					    =  model(__a						,				attention_mask=__a						,				use_cache=__a							)

						__a    ,				__a			:       Union[str, Any]					    =  outputs.to_tuple()

						# create hypothetical multiple next token and extent to next_input_ids
						__a			:       List[Any]					    =  ids_tensor((self.batch_size, 3)						,				config.vocab_size							)
						__a			:       str					    =  ids_tensor((self.batch_size, 3)						,				2							)

						# append to next input_ids and
						__a			:       Optional[Any]					    =  torch.cat([input_ids, next_tokens]						,				dim=-1							)
						__a			:       Tuple					    =  torch.cat([attention_mask, next_attn_mask]						,				dim=-1							)

						__a			:       Optional[Any]					    =  model(__a						,				attention_mask=__a							)['last_hidden_state']
						__a			:       List[Any]					    =  model(__a						,				attention_mask=__a						,				past_key_values=__a							)[
						    'last_hidden_state'
						]

						# select random slice
						__a			:       Any					    =  ids_tensor((1,)						,				output_from_past.shape[-1]							).item()
						__a			:       Tuple					    =  output_from_no_past[:, -3:, random_slice_idx].detach()
						__a			:       Dict					    =  output_from_past[:, :, random_slice_idx].detach()

						self.parent.assertTrue(output_from_past_slice.shape[1] == next_tokens.shape[1]							)

						# test that outputs are equal for slice
						self.parent.assertTrue(torch.allclose(__a						,				__a						,				atol=1E-3							)							)




	def       __UpperCAmelCase							(   self						,				__a						,				__a						,				__a						,				__a						,				__a						,				*__a						,				__a=False							):

						'''simple docstring'''





						__a			:       List[Any]					    =  BioGptForCausalLM(__a							)
						model.to(__a							)
						if gradient_checkpointing:
											model.gradient_checkpointing_enable()

						__a			:       Any					    =  model(__a						,				labels=__a							)
						self.parent.assertEqual(result.loss.shape						,				()							)
						self.parent.assertEqual(result.logits.shape						,				(self.batch_size, self.seq_length, self.vocab_size)							)
						result.loss.backward()




	def       __UpperCAmelCase							(   self						,				__a						,				*__a							):

						'''simple docstring'''





						__a			:       Union[str, Any]					    =  BioGptModel(__a							)
						__a			:       str					    =  model.config.initializer_range / math.sqrt(2 * model.config.num_hidden_layers							)
						for key in model.state_dict().keys():
											if "c_proj" in key and "weight" in key:
																self.parent.assertLessEqual(abs(torch.std(model.state_dict()[key]							) - model_std							)						,				0.001							)
																self.parent.assertLessEqual(abs(torch.mean(model.state_dict()[key]							) - 0.0							)						,				0.01							)




	def       __UpperCAmelCase							(   self						,				__a						,				__a						,				__a						,				__a						,				__a						,				*__a							):

						'''simple docstring'''





						__a			:       List[str]					    =  self.num_labels
						__a			:       Optional[int]					    =  BioGptForTokenClassification(__a							)
						model.to(__a							)
						model.eval()
						__a			:       Tuple					    =  model(__a						,				attention_mask=__a						,				token_type_ids=__a							)
						self.parent.assertEqual(result.logits.shape						,				(self.batch_size, self.seq_length, self.num_labels)							)





	def       __UpperCAmelCase							(   self							):

						'''simple docstring'''





						__a			:       Dict					    =  self.prepare_config_and_inputs()
						(
						    (
						    __a
						)    ,				(
						    __a
						)    ,				(
						    __a
						)    ,				(
						    __a
						)    ,				(
						    __a
						)    ,				(
						    __a
						)    ,				(
						    __a
						)    ,				
						)			:       Optional[int]					    =  config_and_inputs
						__a			:       int					    =  {'input_ids': input_ids, 'attention_mask': input_mask}
						return config, inputs_dict





@require_torch
class 							__UpperCamelCase				(		lowerCAmelCase_		,      lowerCAmelCase_		,      lowerCAmelCase_		,      unittest.TestCase					):
	A_				=    (
	    (BioGptModel, BioGptForCausalLM, BioGptForSequenceClassification, BioGptForTokenClassification)
	    if is_torch_available()
	    else ()
	)
	A_				=    (BioGptForCausalLM,) if is_torch_available() else ()
	A_				=    (
	    {
	        "feature-extraction": BioGptModel,
	        "text-classification": BioGptForSequenceClassification,
	        "text-generation": BioGptForCausalLM,
	        "token-classification": BioGptForTokenClassification,
	        "zero-shot": BioGptForSequenceClassification,
	    }
	    if is_torch_available()
	    else {}
	)
	A_				=    False




	def       __UpperCAmelCase							(   self							):

						'''simple docstring'''





						__a			:       Optional[Any]					    =  BioGptModelTester(self							)
						__a			:       Optional[int]					    =  ConfigTester(self						,				config_class=__a						,				hidden_size=37							)




	def       __UpperCAmelCase							(   self							):

						'''simple docstring'''





						self.config_tester.run_common_tests()




	def       __UpperCAmelCase							(   self							):

						'''simple docstring'''





						__a			:       List[Any]					    =  self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_model(*__a							)




	def       __UpperCAmelCase							(   self							):

						'''simple docstring'''





						__a			:       int					    =  self.model_tester.prepare_config_and_inputs()
						for type in ["absolute", "relative_key", "relative_key_query"]:
											__a			:       Union[str, Any]					    =  type
											self.model_tester.create_and_check_model(*__a							)




	def       __UpperCAmelCase							(   self							):

						'''simple docstring'''





						__a			:       Dict					    =  self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_biogpt_model_attention_mask_past(*__a							)




	def       __UpperCAmelCase							(   self							):

						'''simple docstring'''





						__a			:       Tuple					    =  self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_forward_and_backwards(*__a						,				gradient_checkpointing=__a							)




	def       __UpperCAmelCase							(   self							):

						'''simple docstring'''





						__a			:       int					    =  self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_biogpt_model_past_large_inputs(*__a							)




	def       __UpperCAmelCase							(   self							):

						'''simple docstring'''





						__a			:       int					    =  self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_biogpt_weight_initialization(*__a							)




	def       __UpperCAmelCase							(   self							):

						'''simple docstring'''





						__a			:       Any					    =  self.model_tester.prepare_config_and_inputs()
						self.model_tester.create_and_check_biogpt_for_token_classification(*__a							)




	@slow
	def       __UpperCAmelCase							(   self							):

						'''simple docstring'''





						__a			:       List[str]					    =  BioGptForCausalLM.from_pretrained('microsoft/biogpt'							)
						model.to(__a							)
						__a			:       List[Any]					    =  BioGptTokenizer.from_pretrained('microsoft/biogpt'							)

						__a			:       Optional[int]					    =  'left'

						# Define PAD Token = EOS Token = 50256
						__a			:       Union[str, Any]					    =  tokenizer.eos_token
						__a			:       Tuple					    =  model.config.eos_token_id

						# use different length sentences to test batching
						__a			:       Optional[Any]					    =  [
						    'Hello, my dog is a little',
						    'Today, I',
						]

						__a			:       Optional[int]					    =  tokenizer(__a						,				return_tensors='pt'						,				padding=__a							)
						__a			:       Dict					    =  inputs['input_ids'].to(__a							)

						__a			:       List[Any]					    =  model.generate(
						    input_ids=__a						,				attention_mask=inputs['attention_mask'].to(__a							)						,				)

						__a			:       Tuple					    =  tokenizer(sentences[0]						,				return_tensors='pt'							).input_ids.to(__a							)
						__a			:       List[Any]					    =  model.generate(input_ids=__a							)

						__a			:       List[str]					    =  inputs_non_padded.shape[-1] - inputs['attention_mask'][-1].long().sum().cpu().item()
						__a			:       Optional[Any]					    =  tokenizer(sentences[1]						,				return_tensors='pt'							).input_ids.to(__a							)
						__a			:       Any					    =  model.generate(input_ids=__a						,				max_length=model.config.max_length - num_paddings							)

						__a			:       Tuple					    =  tokenizer.batch_decode(__a						,				skip_special_tokens=__a							)
						__a			:       Union[str, Any]					    =  tokenizer.decode(output_non_padded[0]						,				skip_special_tokens=__a							)
						__a			:       Dict					    =  tokenizer.decode(output_padded[0]						,				skip_special_tokens=__a							)

						__a			:       Optional[Any]					    =  [
						    'Hello, my dog is a little bit bigger than a little bit.',
						    'Today, I have a good idea of how to use the information',
						]
						self.assertListEqual(__a						,				__a							)
						self.assertListEqual(__a						,				[non_padded_sentence, padded_sentence]							)




	@slow
	def       __UpperCAmelCase							(   self							):

						'''simple docstring'''





						for model_name in BIOGPT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
											__a			:       int					    =  BioGptModel.from_pretrained(__a							)
											self.assertIsNotNone(__a							)




	def       __UpperCAmelCase							(   self							):

						'''simple docstring'''





						__a    ,				__a			:       Union[str, Any]					    =  self.model_tester.prepare_config_and_inputs_for_common()
						__a			:       Tuple					    =  3
						__a			:       Optional[int]					    =  input_dict['input_ids']
						__a			:       int					    =  input_ids.ne(1							).to(__a							)
						__a			:       Optional[int]					    =  ids_tensor([self.model_tester.batch_size]						,				self.model_tester.type_sequence_label_size							)
						__a			:       Optional[int]					    =  BioGptForSequenceClassification(__a							)
						model.to(__a							)
						model.eval()
						__a			:       Tuple					    =  model(__a						,				attention_mask=__a						,				labels=__a							)
						self.assertEqual(result.logits.shape						,				(self.model_tester.batch_size, self.model_tester.num_labels)							)





	def       __UpperCAmelCase							(   self							):

						'''simple docstring'''





						__a    ,				__a			:       int					    =  self.model_tester.prepare_config_and_inputs_for_common()
						__a			:       str					    =  3
						__a			:       List[str]					    =  'multi_label_classification'
						__a			:       Optional[Any]					    =  input_dict['input_ids']
						__a			:       List[Any]					    =  input_ids.ne(1							).to(__a							)
						__a			:       Any					    =  ids_tensor(
						    [self.model_tester.batch_size, config.num_labels]						,				self.model_tester.type_sequence_label_size							).to(torch.float							)
						__a			:       Dict					    =  BioGptForSequenceClassification(__a							)
						model.to(__a							)
						model.eval()
						__a			:       Tuple					    =  model(__a						,				attention_mask=__a						,				labels=__a							)
						self.assertEqual(result.logits.shape						,				(self.model_tester.batch_size, self.model_tester.num_labels)							)





@require_torch
class 							__UpperCamelCase				(		unittest.TestCase					):




	@slow
	def       __UpperCAmelCase							(   self							):

						'''simple docstring'''





						__a			:       List[str]					    =  BioGptForCausalLM.from_pretrained('microsoft/biogpt'							)
						__a			:       Optional[int]					    =  torch.tensor([[2, 4805, 9, 656, 21]]							)
						__a			:       Dict					    =  model(__a							)[0]

						__a			:       int					    =  4_2384

						__a			:       int					    =  torch.Size((1, 5, vocab_size)							)
						self.assertEqual(output.shape						,				__a							)

						__a			:       str					    =  torch.tensor(
						    [[[-9.5236, -9.8918, 10.4557], [-11.0469, -9.6423, 8.1022], [-8.8664, -7.8826, 5.5325]]]							)

						self.assertTrue(torch.allclose(output[:, :3, :3]						,				__a						,				atol=1E-4							)							)





	@slow
	def       __UpperCAmelCase							(   self							):

						'''simple docstring'''





						__a			:       Tuple					    =  BioGptTokenizer.from_pretrained('microsoft/biogpt'							)
						__a			:       List[Any]					    =  BioGptForCausalLM.from_pretrained('microsoft/biogpt'							)
						model.to(__a							)

						torch.manual_seed(0							)
						__a			:       int					    =  tokenizer('COVID-19 is'						,				return_tensors='pt'							).to(__a							)
						__a			:       Optional[int]					    =  model.generate(
						    **__a						,				min_length=100						,				max_length=1024						,				num_beams=5						,				early_stopping=__a						,				)
						__a			:       int					    =  tokenizer.decode(output_ids[0]						,				skip_special_tokens=__a							)

						__a			:       List[Any]					    =  (
						    'COVID-19 is a global pandemic caused by severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2), the'
						    ' causative agent of coronavirus disease 2019 (COVID-19), which has spread to more than 200 countries and'
						    ' territories, including the United States (US), Canada, Australia, New Zealand, the United Kingdom (UK),'
						    ' and the United States of America (USA), as of March 11, 2020, with more than 800,000 confirmed cases and'
						    ' more than 800,000 deaths.'
						)
						self.assertEqual(__a						,				__a							)







'''simple docstring'''



import re
import string

import numpy as np

import datasets


__lowercase	:						Tuple       =	'\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	:						Any       =	'\n'





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




	def       __UpperCAmelCase							(   self							):

						'''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       __UpperCAmelCase							(   self						,				__a						,				__a						,				__a=None						,				__a=False						,				__a=False						,				__a=False						,				):

						'''simple docstring'''





						if regexes_to_ignore is not None:
											for s in regexes_to_ignore:
																__a			:       Tuple					    =  np.array([re.sub(__a						,				''						,				__a							) for x in predictions]							)
																__a			:       List[Any]					    =  np.array([re.sub(__a						,				''						,				__a							) for x in references]							)
						else:
											__a			:       int					    =  np.asarray(__a							)
											__a			:       str					    =  np.asarray(__a							)

						if ignore_case:
											__a			:       Dict					    =  np.char.lower(__a							)
											__a			:       List[str]					    =  np.char.lower(__a							)

						if ignore_punctuation:
											__a			:       Dict					    =  string.punctuation.maketrans(''						,				''						,				string.punctuation							)
											__a			:       Tuple					    =  np.char.translate(__a						,				table=__a							)
											__a			:       Dict					    =  np.char.translate(__a						,				table=__a							)

						if ignore_numbers:
											__a			:       Optional[int]					    =  string.digits.maketrans(''						,				''						,				string.digits							)
											__a			:       Tuple					    =  np.char.translate(__a						,				table=__a							)
											__a			:       Optional[int]					    =  np.char.translate(__a						,				table=__a							)

						__a			:       Any					    =  predictions == references

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



