


import re
import string
from collections import Counter

import sacrebleu
import sacremoses
from packaging import version

import datasets


__UpperCamelCase       :       List[Any]						       =				"\n@inproceedings{xu-etal-2016-optimizing,\n    title = {Optimizing Statistical Machine Translation for Text Simplification},\n    authors={Xu, Wei and Napoles, Courtney and Pavlick, Ellie and Chen, Quanze and Callison-Burch, Chris},\n    journal = {Transactions of the Association for Computational Linguistics},\n    volume = {4},\n    year={2016},\n    url = {https://www.aclweb.org/anthology/Q16-1029},\n    pages = {401--415\n},\n@inproceedings{post-2018-call,\n    title = \"A Call for Clarity in Reporting {BLEU} Scores\",\n    author = \"Post, Matt\",\n    booktitle = \"Proceedings of the Third Conference on Machine Translation: Research Papers\",\n    month = oct,\n    year = \"2018\",\n    address = \"Belgium, Brussels\",\n    publisher = \"Association for Computational Linguistics\",\n    url = \"https://www.aclweb.org/anthology/W18-6319\",\n    pages = \"186--191\",\n}\n"

__UpperCamelCase       :       str						       =				"\\nWIKI_SPLIT is the combination of three metrics SARI, EXACT and SACREBLEU\nIt can be used to evaluate the quality of machine-generated texts.\n"


__UpperCamelCase       :       str						       =				"\nCalculates sari score (between 0 and 100) given a list of source and predicted\nsentences, and a list of lists of reference sentences. It also computes the BLEU score as well as the exact match score.\nArgs:\n    sources: list of source sentences where each sentence should be a string.\n    predictions: list of predicted sentences where each sentence should be a string.\n    references: list of lists of reference sentences where each sentence should be a string.\nReturns:\n    sari: sari score\n    sacrebleu: sacrebleu score\n    exact: exact score\n\nExamples:\n    >>> sources=[\"About 95 species are currently accepted .\"]\n    >>> predictions=[\"About 95 you now get in .\"]\n    >>> references=[[\"About 95 species are currently known .\"]]\n    >>> wiki_split = datasets.load_metric(\"wiki_split\")\n    >>> results = wiki_split.compute(sources=sources, predictions=predictions, references=references)\n    >>> print(results)\n    {'sari': 21.805555555555557, 'sacrebleu': 14.535768424205482, 'exact': 0.0}\n"

def 			_a  (				SCREAMING_SNAKE_CASE	:				Any     ):







 """simple docstring"""



 def remove_articles(SCREAMING_SNAKE_CASE	:				Union[str, Any]     ):
  UpperCamelCase__					:    Tuple          =   re.compile(r'''\b(a|an|the)\b'''    , re.UNICODE     )
  return re.sub(SCREAMING_SNAKE_CASE    , ''' '''    , SCREAMING_SNAKE_CASE     )

 def white_space_fix(SCREAMING_SNAKE_CASE	:				Tuple     ):
  return " ".join(text.split()     )

 def remove_punc(SCREAMING_SNAKE_CASE	:				Union[str, Any]     ):
  UpperCamelCase__					:    Optional[Any]          =   set(string.punctuation     )
  return "".join(ch for ch in text if ch not in exclude     )

 def lower(SCREAMING_SNAKE_CASE	:				Optional[Any]     ):
  return text.lower()

 return white_space_fix(remove_articles(remove_punc(lower(SCREAMING_SNAKE_CASE     )     )     )     )

def 			_a  (				SCREAMING_SNAKE_CASE	:				str    , SCREAMING_SNAKE_CASE	:				List[Any]     ):







 """simple docstring"""



 return int(normalize_answer(SCREAMING_SNAKE_CASE     ) == normalize_answer(SCREAMING_SNAKE_CASE     )     )

def 			_a  (				SCREAMING_SNAKE_CASE	:				str    , SCREAMING_SNAKE_CASE	:				Tuple     ):







 """simple docstring"""



 UpperCamelCase__					:    List[Any]          =   [any(compute_exact(SCREAMING_SNAKE_CASE    , SCREAMING_SNAKE_CASE     ) for ref in refs     ) for pred, refs in zip(SCREAMING_SNAKE_CASE    , SCREAMING_SNAKE_CASE     )]
 return (sum(SCREAMING_SNAKE_CASE     ) / len(SCREAMING_SNAKE_CASE     )) * 100

def 			_a  (				SCREAMING_SNAKE_CASE	:				Tuple    , SCREAMING_SNAKE_CASE	:				Optional[Any]    , SCREAMING_SNAKE_CASE	:				Any    , SCREAMING_SNAKE_CASE	:				List[Any]     ):







 """simple docstring"""



 UpperCamelCase__					:    int          =   [rgram for rgrams in rgramslist for rgram in rgrams]
 UpperCamelCase__					:    int          =   Counter(SCREAMING_SNAKE_CASE     )

 UpperCamelCase__					:    str          =   Counter(SCREAMING_SNAKE_CASE     )
 UpperCamelCase__					:    Union[str, Any]          =   Counter()
 for sgram, scount in sgramcounter.items():
  UpperCamelCase__					:    List[str]          =   scount * numref

 UpperCamelCase__					:    Tuple          =   Counter(SCREAMING_SNAKE_CASE     )
 UpperCamelCase__					:    int          =   Counter()
 for cgram, ccount in cgramcounter.items():
  UpperCamelCase__					:    List[str]          =   ccount * numref

 # KEEP
 UpperCamelCase__					:    Tuple          =   sgramcounter_rep & cgramcounter_rep
 UpperCamelCase__					:    Any          =   keepgramcounter_rep & rgramcounter
 UpperCamelCase__					:    Union[str, Any]          =   sgramcounter_rep & rgramcounter

 UpperCamelCase__					:    Optional[int]          =   0
 UpperCamelCase__					:    List[Any]          =   0
 for keepgram in keepgramcountergood_rep:
  keeptmpscorea += keepgramcountergood_rep[keepgram] / keepgramcounter_rep[keepgram]
  # Fix an alleged bug [2] in the keep score computation.
  # keeptmpscore2 += keepgramcountergood_rep[keepgram] / keepgramcounterall_rep[keepgram]
  keeptmpscorea += keepgramcountergood_rep[keepgram]
 # Define 0/0=1 instead of 0 to give higher scores for predictions that match
 #      a target exactly.
 UpperCamelCase__					:    int          =   1
 UpperCamelCase__					:    List[Any]          =   1
 if len(SCREAMING_SNAKE_CASE     ) > 0:
  UpperCamelCase__					:    str          =   keeptmpscorea / len(SCREAMING_SNAKE_CASE     )
 if len(SCREAMING_SNAKE_CASE     ) > 0:
  # Fix an alleged bug [2] in the keep score computation.
  # keepscore_recall = keeptmpscore2 / len(keepgramcounterall_rep)
  UpperCamelCase__					:    List[str]          =   keeptmpscorea / sum(keepgramcounterall_rep.values()     )
 UpperCamelCase__					:    str          =   0
 if keepscore_precision > 0 or keepscore_recall > 0:
  UpperCamelCase__					:    Any          =   2 * keepscore_precision * keepscore_recall / (keepscore_precision + keepscore_recall)

 # DELETION
 UpperCamelCase__					:    List[Any]          =   sgramcounter_rep - cgramcounter_rep
 UpperCamelCase__					:    Tuple          =   delgramcounter_rep - rgramcounter
 UpperCamelCase__					:    int          =   sgramcounter_rep - rgramcounter
 UpperCamelCase__					:    Any          =   0
 UpperCamelCase__					:    List[Any]          =   0
 for delgram in delgramcountergood_rep:
  deltmpscorea += delgramcountergood_rep[delgram] / delgramcounter_rep[delgram]
  deltmpscorea += delgramcountergood_rep[delgram] / delgramcounterall_rep[delgram]
 # Define 0/0=1 instead of 0 to give higher scores for predictions that match
 # a target exactly.
 UpperCamelCase__					:    Union[str, Any]          =   1
 if len(SCREAMING_SNAKE_CASE     ) > 0:
  UpperCamelCase__					:    Dict          =   deltmpscorea / len(SCREAMING_SNAKE_CASE     )

 # ADDITION
 UpperCamelCase__					:    List[Any]          =   set(SCREAMING_SNAKE_CASE     ) - set(SCREAMING_SNAKE_CASE     )
 UpperCamelCase__					:    List[Any]          =   set(SCREAMING_SNAKE_CASE     ) & set(SCREAMING_SNAKE_CASE     )
 UpperCamelCase__					:    Tuple          =   set(SCREAMING_SNAKE_CASE     ) - set(SCREAMING_SNAKE_CASE     )

 UpperCamelCase__					:    List[str]          =   0
 for addgram in addgramcountergood:
  addtmpscore += 1

 # Define 0/0=1 instead of 0 to give higher scores for predictions that match
 # a target exactly.
 UpperCamelCase__					:    Optional[Any]          =   1
 UpperCamelCase__					:    int          =   1
 if len(SCREAMING_SNAKE_CASE     ) > 0:
  UpperCamelCase__					:    Tuple          =   addtmpscore / len(SCREAMING_SNAKE_CASE     )
 if len(SCREAMING_SNAKE_CASE     ) > 0:
  UpperCamelCase__					:    str          =   addtmpscore / len(SCREAMING_SNAKE_CASE     )
 UpperCamelCase__					:    Tuple          =   0
 if addscore_precision > 0 or addscore_recall > 0:
  UpperCamelCase__					:    Tuple          =   2 * addscore_precision * addscore_recall / (addscore_precision + addscore_recall)

 return (keepscore, delscore_precision, addscore)

def 			_a  (				SCREAMING_SNAKE_CASE	:				List[Any]    , SCREAMING_SNAKE_CASE	:				Union[str, Any]    , SCREAMING_SNAKE_CASE	:				Optional[Any]     ):







 """simple docstring"""



 UpperCamelCase__					:    Optional[Any]          =   len(SCREAMING_SNAKE_CASE     )

 UpperCamelCase__					:    List[str]          =   ssent.split(''' '''     )
 UpperCamelCase__					:    List[Any]          =   csent.split(''' '''     )
 UpperCamelCase__					:    int          =   []
 UpperCamelCase__					:    Optional[int]          =   []
 UpperCamelCase__					:    str          =   []
 UpperCamelCase__					:    Dict          =   []
 UpperCamelCase__					:    Optional[Any]          =   []
 UpperCamelCase__					:    List[str]          =   []

 UpperCamelCase__					:    int          =   []
 UpperCamelCase__					:    Optional[Any]          =   []
 UpperCamelCase__					:    Optional[Any]          =   []
 UpperCamelCase__					:    Optional[Any]          =   []
 for rsent in rsents:
  UpperCamelCase__					:    List[Any]          =   rsent.split(''' '''     )
  UpperCamelCase__					:    List[str]          =   []
  UpperCamelCase__					:    Optional[int]          =   []
  UpperCamelCase__					:    Dict          =   []
  ragramslist.append(SCREAMING_SNAKE_CASE     )
  for i in range(0    , len(SCREAMING_SNAKE_CASE     ) - 1     ):
   if i < len(SCREAMING_SNAKE_CASE     ) - 1:
    UpperCamelCase__					:    int          =   ragrams[i] + ''' ''' + ragrams[i + 1]
    ragrams.append(SCREAMING_SNAKE_CASE     )
   if i < len(SCREAMING_SNAKE_CASE     ) - 2:
    UpperCamelCase__					:    str          =   ragrams[i] + ''' ''' + ragrams[i + 1] + ''' ''' + ragrams[i + 2]
    ragrams.append(SCREAMING_SNAKE_CASE     )
   if i < len(SCREAMING_SNAKE_CASE     ) - 3:
    UpperCamelCase__					:    List[Any]          =   ragrams[i] + ''' ''' + ragrams[i + 1] + ''' ''' + ragrams[i + 2] + ''' ''' + ragrams[i + 3]
    ragrams.append(SCREAMING_SNAKE_CASE     )
  ragramslist.append(SCREAMING_SNAKE_CASE     )
  ragramslist.append(SCREAMING_SNAKE_CASE     )
  ragramslist.append(SCREAMING_SNAKE_CASE     )

 for i in range(0    , len(SCREAMING_SNAKE_CASE     ) - 1     ):
  if i < len(SCREAMING_SNAKE_CASE     ) - 1:
   UpperCamelCase__					:    List[Any]          =   sagrams[i] + ''' ''' + sagrams[i + 1]
   sagrams.append(SCREAMING_SNAKE_CASE     )
  if i < len(SCREAMING_SNAKE_CASE     ) - 2:
   UpperCamelCase__					:    Optional[int]          =   sagrams[i] + ''' ''' + sagrams[i + 1] + ''' ''' + sagrams[i + 2]
   sagrams.append(SCREAMING_SNAKE_CASE     )
  if i < len(SCREAMING_SNAKE_CASE     ) - 3:
   UpperCamelCase__					:    Any          =   sagrams[i] + ''' ''' + sagrams[i + 1] + ''' ''' + sagrams[i + 2] + ''' ''' + sagrams[i + 3]
   sagrams.append(SCREAMING_SNAKE_CASE     )

 for i in range(0    , len(SCREAMING_SNAKE_CASE     ) - 1     ):
  if i < len(SCREAMING_SNAKE_CASE     ) - 1:
   UpperCamelCase__					:    Dict          =   cagrams[i] + ''' ''' + cagrams[i + 1]
   cagrams.append(SCREAMING_SNAKE_CASE     )
  if i < len(SCREAMING_SNAKE_CASE     ) - 2:
   UpperCamelCase__					:    str          =   cagrams[i] + ''' ''' + cagrams[i + 1] + ''' ''' + cagrams[i + 2]
   cagrams.append(SCREAMING_SNAKE_CASE     )
  if i < len(SCREAMING_SNAKE_CASE     ) - 3:
   UpperCamelCase__					:    str          =   cagrams[i] + ''' ''' + cagrams[i + 1] + ''' ''' + cagrams[i + 2] + ''' ''' + cagrams[i + 3]
   cagrams.append(SCREAMING_SNAKE_CASE     )

 ((UpperCamelCase__)       ,				(UpperCamelCase__)       ,				(UpperCamelCase__))					:    Union[str, Any]          =   SARIngram(SCREAMING_SNAKE_CASE    , SCREAMING_SNAKE_CASE    , SCREAMING_SNAKE_CASE    , SCREAMING_SNAKE_CASE     )
 ((UpperCamelCase__)       ,				(UpperCamelCase__)       ,				(UpperCamelCase__))					:    Optional[Any]          =   SARIngram(SCREAMING_SNAKE_CASE    , SCREAMING_SNAKE_CASE    , SCREAMING_SNAKE_CASE    , SCREAMING_SNAKE_CASE     )
 ((UpperCamelCase__)       ,				(UpperCamelCase__)       ,				(UpperCamelCase__))					:    Dict          =   SARIngram(SCREAMING_SNAKE_CASE    , SCREAMING_SNAKE_CASE    , SCREAMING_SNAKE_CASE    , SCREAMING_SNAKE_CASE     )
 ((UpperCamelCase__)       ,				(UpperCamelCase__)       ,				(UpperCamelCase__))					:    Tuple          =   SARIngram(SCREAMING_SNAKE_CASE    , SCREAMING_SNAKE_CASE    , SCREAMING_SNAKE_CASE    , SCREAMING_SNAKE_CASE     )
 UpperCamelCase__					:    Union[str, Any]          =   sum([keepascore, keepascore, keepascore, keepascore]     ) / 4
 UpperCamelCase__					:    int          =   sum([delascore, delascore, delascore, delascore]     ) / 4
 UpperCamelCase__					:    Optional[int]          =   sum([addascore, addascore, addascore, addascore]     ) / 4
 UpperCamelCase__					:    List[Any]          =   (avgkeepscore + avgdelscore + avgaddscore) / 3
 return finalscore

def 			_a  (				SCREAMING_SNAKE_CASE	:				Dict    , SCREAMING_SNAKE_CASE	:				bool = True    , SCREAMING_SNAKE_CASE	:				str = "13a"    , SCREAMING_SNAKE_CASE	:				bool = True     ):







 """simple docstring"""



 if lowercase:
  UpperCamelCase__					:    Optional[Any]          =   sentence.lower()

 if tokenizer in ["13a", "intl"]:
  if version.parse(sacrebleu.__version__     ).major >= 2:
   UpperCamelCase__					:    List[str]          =   sacrebleu.metrics.bleu._get_tokenizer(SCREAMING_SNAKE_CASE     )()(SCREAMING_SNAKE_CASE     )
  else:
   UpperCamelCase__					:    Optional[Any]          =   sacrebleu.TOKENIZERS[tokenizer]()(SCREAMING_SNAKE_CASE     )
 elif tokenizer == "moses":
  UpperCamelCase__					:    Tuple          =   sacremoses.MosesTokenizer().tokenize(SCREAMING_SNAKE_CASE    , return_str=SCREAMING_SNAKE_CASE    , escape=SCREAMING_SNAKE_CASE     )
 elif tokenizer == "penn":
  UpperCamelCase__					:    Dict          =   sacremoses.MosesTokenizer().penn_tokenize(SCREAMING_SNAKE_CASE    , return_str=SCREAMING_SNAKE_CASE     )
 else:
  UpperCamelCase__					:    List[Any]          =   sentence

 if not return_str:
  UpperCamelCase__					:    str          =   normalized_sent.split()

 return normalized_sent

def 			_a  (				SCREAMING_SNAKE_CASE	:				Optional[Any]    , SCREAMING_SNAKE_CASE	:				str    , SCREAMING_SNAKE_CASE	:				List[Any]     ):







 """simple docstring"""



 if not (len(SCREAMING_SNAKE_CASE     ) == len(SCREAMING_SNAKE_CASE     ) == len(SCREAMING_SNAKE_CASE     )):
  raise ValueError('''Sources length must match predictions and references lengths.'''     )
 UpperCamelCase__					:    List[Any]          =   0
 for src, pred, refs in zip(SCREAMING_SNAKE_CASE    , SCREAMING_SNAKE_CASE    , SCREAMING_SNAKE_CASE     ):
  sari_score += SARIsent(normalize(SCREAMING_SNAKE_CASE     )    , normalize(SCREAMING_SNAKE_CASE     )    , [normalize(SCREAMING_SNAKE_CASE     ) for sent in refs]     )
 UpperCamelCase__					:    List[Any]          =   sari_score / len(SCREAMING_SNAKE_CASE     )
 return 100 * sari_score

def 			_a  (				SCREAMING_SNAKE_CASE	:				Tuple    , SCREAMING_SNAKE_CASE	:				Union[str, Any]    , SCREAMING_SNAKE_CASE	:				Tuple="exp"    , SCREAMING_SNAKE_CASE	:				int=None    , SCREAMING_SNAKE_CASE	:				Dict=False    , SCREAMING_SNAKE_CASE	:				str=False    , SCREAMING_SNAKE_CASE	:				int=False    , ):







 """simple docstring"""



 UpperCamelCase__					:    List[Any]          =   len(references[0]     )
 if any(len(SCREAMING_SNAKE_CASE     ) != references_per_prediction for refs in references     ):
  raise ValueError('''Sacrebleu requires the same number of references for each prediction'''     )
 UpperCamelCase__					:    str          =   [[refs[i] for refs in references] for i in range(SCREAMING_SNAKE_CASE     )]
 UpperCamelCase__					:    Any          =   sacrebleu.corpus_bleu(
     SCREAMING_SNAKE_CASE    , SCREAMING_SNAKE_CASE    , smooth_method=SCREAMING_SNAKE_CASE    , smooth_value=SCREAMING_SNAKE_CASE    , force=SCREAMING_SNAKE_CASE    , lowercase=SCREAMING_SNAKE_CASE    , use_effective_order=SCREAMING_SNAKE_CASE    , )
 return output.score






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


     def      UpperCAmelCase__	(      self							:     List[str]			)  ->      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.Sequence(datasets.Value('''string'''							,	id='''sequence'''			)							,	id='''references'''			),
              }			)							,	codebase_urls=[
              '''https://github.com/huggingface/transformers/blob/master/src/transformers/data/metrics/squad_metrics.py''',
              '''https://github.com/cocoxu/simplification/blob/master/SARI.py''',
              '''https://github.com/tensorflow/tensor2tensor/blob/master/tensor2tensor/utils/sari_hook.py''',
              '''https://github.com/mjpost/sacreBLEU''',
          ]							,	reference_urls=[
              '''https://www.aclweb.org/anthology/Q16-1029.pdf''',
              '''https://github.com/mjpost/sacreBLEU''',
              '''https://en.wikipedia.org/wiki/BLEU''',
              '''https://towardsdatascience.com/evaluating-text-output-in-nlp-bleu-at-your-own-risk-e8609665a213''',
          ]							,	)


     def      UpperCAmelCase__	(      self							:     str							,	lowerCamelCase__							:     int							,	lowerCamelCase__							:     str							,	lowerCamelCase__							:     Optional[Any]			)  ->      List[Any]:





      '''simple docstring'''






      UpperCamelCase__					:    List[Any]          =   {}
      result.update({'''sari''': compute_sari(sources=lowerCamelCase__							,	predictions=lowerCamelCase__							,	references=lowerCamelCase__			)}			)
      result.update({'''sacrebleu''': compute_sacrebleu(predictions=lowerCamelCase__							,	references=lowerCamelCase__			)}			)
      result.update({'''exact''': compute_em(predictions=lowerCamelCase__							,	references=lowerCamelCase__			)}			)
      return result






import contextlib
import importlib
import io
import unittest

import transformers

# Try to import everything from transformers to ensure every object can be loaded.
from transformers import *  # noqa F406
from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER, require_flax, require_tf, require_torch
from transformers.utils import ContextManagers, find_labels, is_flax_available, is_tf_available, is_torch_available


if is_torch_available():
       from transformers import BertForPreTraining, BertForQuestionAnswering, BertForSequenceClassification

if is_tf_available():
       from transformers import TFBertForPreTraining, TFBertForQuestionAnswering, TFBertForSequenceClassification

if is_flax_available():
       from transformers import FlaxBertForPreTraining, FlaxBertForQuestionAnswering, FlaxBertForSequenceClassification


__UpperCamelCase       :       Dict						       =				DUMMY_UNKNOWN_IDENTIFIER
# An actual model hosted on huggingface.co

__UpperCamelCase       :       Optional[int]						       =				"main"
# Default branch name
__UpperCamelCase       :       Optional[Any]						       =				"f2c752cfc5c0ab6f4bdec59acea69eefbee381c2"
# One particular commit (not the top of `main`)
__UpperCamelCase       :       str						       =				"aaaaaaa"
# This commit does not exist, so we should 404.

__UpperCamelCase       :       Optional[Any]						       =				"d9e9f15bc825e4b2c9249e9578f884bbcb5e3684"
# Sha-1 of config.json on the top of `main`, for checking purposes
__UpperCamelCase       :       Tuple						       =				"4b243c475af8d0a7754e87d7d096c92e5199ec2fe168a2ee7998e3b8e9bcb1d3"

@contextlib.contextmanager
def 			_a  (				):







 """simple docstring"""



 print('''Welcome!'''     )
 yield
 print('''Bye!'''     )

@contextlib.contextmanager
def 			_a  (				):







 """simple docstring"""



 print('''Bonjour!'''     )
 yield
 print('''Au revoir!'''     )

class       __magic_name__	(     unittest.TestCase):


     def      UpperCAmelCase__	(      self							:     Union[str, Any]			)  ->      Any:





      '''simple docstring'''






      assert transformers.__spec__ is not None
      assert importlib.util.find_spec('''transformers'''			) is not None



class       __magic_name__	(     unittest.TestCase):


     @unittest.mock.patch('''sys.stdout'''							,	new_callable=io.StringIO			)
     def      UpperCAmelCase__	(      self							:     Union[str, Any]							,	lowerCamelCase__							:     Union[str, Any]			)  ->      Optional[Any]:





      '''simple docstring'''






      with ContextManagers([]			):
       print('''Transformers are awesome!'''			)
      # The print statement adds a new line at the end of the output
      self.assertEqual(mock_stdout.getvalue()							,	'''Transformers are awesome!\n'''			)


     @unittest.mock.patch('''sys.stdout'''							,	new_callable=io.StringIO			)
     def      UpperCAmelCase__	(      self							:     Any							,	lowerCamelCase__							:     Union[str, Any]			)  ->      Dict:





      '''simple docstring'''






      with ContextManagers([context_en()]			):
       print('''Transformers are awesome!'''			)
      # The output should be wrapped with an English welcome and goodbye
      self.assertEqual(mock_stdout.getvalue()							,	'''Welcome!\nTransformers are awesome!\nBye!\n'''			)


     @unittest.mock.patch('''sys.stdout'''							,	new_callable=io.StringIO			)
     def      UpperCAmelCase__	(      self							:     List[Any]							,	lowerCamelCase__							:     List[str]			)  ->      Tuple:





      '''simple docstring'''






      with ContextManagers([context_fr(), context_en()]			):
       print('''Transformers are awesome!'''			)
      # The output should be wrapped with an English and French welcome and goodbye
      self.assertEqual(mock_stdout.getvalue()							,	'''Bonjour!\nWelcome!\nTransformers are awesome!\nBye!\nAu revoir!\n'''			)


     @require_torch
     def      UpperCAmelCase__	(      self							:     Tuple			)  ->      Optional[int]:





      '''simple docstring'''






      self.assertEqual(find_labels(lowerCamelCase__			)							,	['''labels''']			)
      self.assertEqual(find_labels(lowerCamelCase__			)							,	['''labels''', '''next_sentence_label''']			)
      self.assertEqual(find_labels(lowerCamelCase__			)							,	['''start_positions''', '''end_positions''']			)

      class       __magic_name__	(     __lowerCAmelCase):
           pass



      self.assertEqual(find_labels(lowerCamelCase__			)							,	['''labels''']			)


     @require_tf
     def      UpperCAmelCase__	(      self							:     Union[str, Any]			)  ->      Tuple:





      '''simple docstring'''






      self.assertEqual(find_labels(lowerCamelCase__			)							,	['''labels''']			)
      self.assertEqual(find_labels(lowerCamelCase__			)							,	['''labels''', '''next_sentence_label''']			)
      self.assertEqual(find_labels(lowerCamelCase__			)							,	['''start_positions''', '''end_positions''']			)

      class       __magic_name__	(     __lowerCAmelCase):
           pass



      self.assertEqual(find_labels(lowerCamelCase__			)							,	['''labels''']			)


     @require_flax
     def      UpperCAmelCase__	(      self							:     str			)  ->      Optional[Any]:





      '''simple docstring'''






      self.assertEqual(find_labels(lowerCamelCase__			)							,	[]			)
      self.assertEqual(find_labels(lowerCamelCase__			)							,	[]			)
      self.assertEqual(find_labels(lowerCamelCase__			)							,	[]			)

      class       __magic_name__	(     __lowerCAmelCase):
           pass



      self.assertEqual(find_labels(lowerCamelCase__			)							,	[]			)


