code: 
  
  
  """simple docstring"""
  
  
  
  
  from copy import deepcopy
  from unittest.case import TestCase
  
  import pytest
  
  from datasets.arrow_dataset import Dataset
  from datasets.features import Audio, ClassLabel, Features, Image, Sequence, Value
  from datasets.info import DatasetInfo
  from datasets.tasks import (
      AudioClassification,
      AutomaticSpeechRecognition,
      ImageClassification,
      LanguageModeling,
      QuestionAnsweringExtractive,
      Summarization,
      TextClassification,
      task_template_from_dict,
  )
  from datasets.utils.py_utils import asdict
  
  
  __SCREAMING_SNAKE_CASE					=						{
      """id""": """5733be284776f41900661182""",
      """title""": """University_of_Notre_Dame""",
      """context""": """Architecturally, the school has a Catholic character. Atop the Main Building\'s gold dome is a golden statue of the Virgin Mary. Immediately in front of the Main Building and facing it, is a copper statue of Christ with arms upraised with the legend \"Venite Ad Me Omnes\". Next to the Main Building is the Basilica of the Sacred Heart. Immediately behind the basilica is the Grotto, a Marian place of prayer and reflection. It is a replica of the grotto at Lourdes, France where the Virgin Mary reputedly appeared to Saint Bernadette Soubirous in 1858. At the end of the main drive (and in a direct line that connects through 3 statues and the Gold Dome), is a simple, modern stone statue of Mary.""",
      """question""": """To whom did the Virgin Mary allegedly appear in 1858 in Lourdes France?""",
      """answers""": {"""text""": ["""Saint Bernadette Soubirous"""], """answer_start""": [5_15]},
  }
  
  
  
  @pytest.mark.parametrize(
      "task_cls",		[
          AudioClassification,
          AutomaticSpeechRecognition,
          ImageClassification,
          LanguageModeling,
          QuestionAnsweringExtractive,
          Summarization,
          TextClassification,
      ],		)
  def 						__a      (  a					):
  
  
  
  
  
         """simple docstring"""
  
  
  
  
  
  
  
         _a          =				task_cls()
         _a          =				asdict(a					)
         _a          =				task_template_from_dict(a					)
         assert task == reloaded
  
  
  
  
  
  class __snake_case		:
  
  
  
  
  
  
  
     """simple docstring"""
  
  
  
  
     def SCREAMING_SNAKE_CASE_      (		self							:Tuple       ):
            _a          =				LanguageModeling(text_column="input_text"       )
            assert {"input_text": "text"} == task.column_mapping
  
  
  
  
     def SCREAMING_SNAKE_CASE_      (		self							:Tuple       ):
            _a          =				Features({"text": Value("string"       )}       )
            _a          =				{"text_column": "input_text"}
            _a          =				LanguageModeling.from_dict(UpperCamelCase__       )
            assert "language-modeling" == task.task
            assert input_schema == task.input_schema
  
  
  
  
  
  
  class __snake_case		(					_SCREAMING_SNAKE_CASE      ):
  
  
  
  
  
  
  
     """simple docstring"""
  
  
  
  
     def SCREAMING_SNAKE_CASE_      (		self							:List[Any]       ):
            _a          =				sorted(["pos", "neg"]       )
  
  
  
  
     def SCREAMING_SNAKE_CASE_      (		self							:str       ):
            _a          =				TextClassification(text_column="input_text"				,  label_column="input_label"       )
            self.assertDictEqual({"input_text": "text", "input_label": "labels"}				,  task.column_mapping       )
  
  
  
  
     def SCREAMING_SNAKE_CASE_      (		self							:int       ):
            _a          =				Features({"text": Value("string"       )}       )
            # Labels are cast to tuple during `TextClassification.__post_init__`, so we do the same here
            _a          =				Features({"labels": ClassLabel}       )
            _a          =				{"text_column": "input_text", "label_column": "input_labels"}
            _a          =				TextClassification.from_dict(UpperCamelCase__       )
            self.assertEqual("text-classification"				,  task.task       )
            self.assertEqual(UpperCamelCase__				,  task.input_schema       )
            self.assertEqual(UpperCamelCase__				,  task.label_schema       )
  
  
  
  
     def SCREAMING_SNAKE_CASE_      (		self							:List[Any]       ):
            _a          =				TextClassification(text_column="input_text"				,  label_column="input_label"       )
            self.assertEqual(task.label_schema["labels"]				,  UpperCamelCase__       )
            _a          =				task.align_with_features(Features({"input_label": ClassLabel(names=self.labels       )}       )       )
            self.assertEqual(task.label_schema["labels"]				,  ClassLabel(names=self.labels       )       )
  
  
  
  
  
  
  class __snake_case		(					_SCREAMING_SNAKE_CASE      ):
  
  
  
  
  
  
  
     """simple docstring"""
  
  
  
  
     def SCREAMING_SNAKE_CASE_      (		self							:List[Any]       ):
            _a          =				QuestionAnsweringExtractive(
                context_column="input_context"				,  question_column="input_question"				,  answers_column="input_answers"       )
            self.assertDictEqual(
                {"input_context": "context", "input_question": "question", "input_answers": "answers"}				,  task.column_mapping       )
  
  
  
  
     def SCREAMING_SNAKE_CASE_      (		self							:Tuple       ):
            _a          =				Features({"question": Value("string"       ), "context": Value("string"       )}       )
            _a          =				Features(
                {
                    "answers": Sequence(
                        {
                            "text": Value("string"       ),
                            "answer_start": Value("int32"       ),
                        }       )
                }       )
            _a          =				{
                "context_column": "input_input_context",
                "question_column": "input_question",
                "answers_column": "input_answers",
            }
            _a          =				QuestionAnsweringExtractive.from_dict(UpperCamelCase__       )
            self.assertEqual("question-answering-extractive"				,  task.task       )
            self.assertEqual(UpperCamelCase__				,  task.input_schema       )
            self.assertEqual(UpperCamelCase__				,  task.label_schema       )
  
  
  
  
  
  
  class __snake_case		(					_SCREAMING_SNAKE_CASE      ):
  
  
  
  
  
  
  
     """simple docstring"""
  
  
  
  
     def SCREAMING_SNAKE_CASE_      (		self							:Optional[int]       ):
            _a          =				Summarization(text_column="input_text"				,  summary_column="input_summary"       )
            self.assertDictEqual({"input_text": "text", "input_summary": "summary"}				,  task.column_mapping       )
  
  
  
  
     def SCREAMING_SNAKE_CASE_      (		self							:List[Any]       ):
            _a          =				Features({"text": Value("string"       )}       )
            _a          =				Features({"summary": Value("string"       )}       )
            _a          =				{"text_column": "input_text", "summary_column": "input_summary"}
            _a          =				Summarization.from_dict(UpperCamelCase__       )
            self.assertEqual("summarization"				,  task.task       )
            self.assertEqual(UpperCamelCase__				,  task.input_schema       )
            self.assertEqual(UpperCamelCase__				,  task.label_schema       )
  
  
  
  
  
  
  class __snake_case		(					_SCREAMING_SNAKE_CASE      ):
  
  
  
  
  
  
  
     """simple docstring"""
  
  
  
  
     def SCREAMING_SNAKE_CASE_      (		self							:List[str]       ):
            _a          =				AutomaticSpeechRecognition(audio_column="input_audio"				,  transcription_column="input_transcription"       )
            self.assertDictEqual({"input_audio": "audio", "input_transcription": "transcription"}				,  task.column_mapping       )
  
  
  
  
     def SCREAMING_SNAKE_CASE_      (		self							:int       ):
            _a          =				Features({"audio": Audio()}       )
            _a          =				Features({"transcription": Value("string"       )}       )
            _a          =				{
                "audio_column": "input_audio",
                "transcription_column": "input_transcription",
            }
            _a          =				AutomaticSpeechRecognition.from_dict(UpperCamelCase__       )
            self.assertEqual("automatic-speech-recognition"				,  task.task       )
            self.assertEqual(UpperCamelCase__				,  task.input_schema       )
            self.assertEqual(UpperCamelCase__				,  task.label_schema       )
  
  
  
  
  
  
  class __snake_case		(					_SCREAMING_SNAKE_CASE      ):
  
  
  
  
  
  
  
     """simple docstring"""
  
  
  
  
     def SCREAMING_SNAKE_CASE_      (		self							:int       ):
            _a          =				sorted(["pos", "neg"]       )
  
  
  
  
     def SCREAMING_SNAKE_CASE_      (		self							:List[str]       ):
            _a          =				AudioClassification(audio_column="input_audio"				,  label_column="input_label"       )
            self.assertDictEqual({"input_audio": "audio", "input_label": "labels"}				,  task.column_mapping       )
  
  
  
  
     def SCREAMING_SNAKE_CASE_      (		self							:int       ):
            _a          =				Features({"audio": Audio()}       )
            _a          =				Features({"labels": ClassLabel}       )
            _a          =				{
                "audio_column": "input_image",
                "label_column": "input_label",
            }
            _a          =				AudioClassification.from_dict(UpperCamelCase__       )
            self.assertEqual("audio-classification"				,  task.task       )
            self.assertEqual(UpperCamelCase__				,  task.input_schema       )
            self.assertEqual(UpperCamelCase__				,  task.label_schema       )
  
  
  
  
     def SCREAMING_SNAKE_CASE_      (		self							:str       ):
            _a          =				AudioClassification(audio_column="input_audio"				,  label_column="input_label"       )
            self.assertEqual(task.label_schema["labels"]				,  UpperCamelCase__       )
            _a          =				task.align_with_features(Features({"input_label": ClassLabel(names=self.labels       )}       )       )
            self.assertEqual(task.label_schema["labels"]				,  ClassLabel(names=self.labels       )       )
  
  
  
  
  
  
  class __snake_case		(					_SCREAMING_SNAKE_CASE      ):
  
  
  
  
  
  
  
     """simple docstring"""
  
  
  
  
     def SCREAMING_SNAKE_CASE_      (		self							:Tuple       ):
            _a          =				sorted(["pos", "neg"]       )
  
  
  
  
     def SCREAMING_SNAKE_CASE_      (		self							:Tuple       ):
            _a          =				ImageClassification(image_column="input_image"				,  label_column="input_label"       )
            self.assertDictEqual({"input_image": "image", "input_label": "labels"}				,  task.column_mapping       )
  
  
  
  
     def SCREAMING_SNAKE_CASE_      (		self							:Tuple       ):
            _a          =				Features({"image": Image()}       )
            _a          =				Features({"labels": ClassLabel}       )
            _a          =				{
                "image_column": "input_image",
                "label_column": "input_label",
            }
            _a          =				ImageClassification.from_dict(UpperCamelCase__       )
            self.assertEqual("image-classification"				,  task.task       )
            self.assertEqual(UpperCamelCase__				,  task.input_schema       )
            self.assertEqual(UpperCamelCase__				,  task.label_schema       )
  
  
  
  
     def SCREAMING_SNAKE_CASE_      (		self							:Optional[Any]       ):
            _a          =				ImageClassification(image_column="input_image"				,  label_column="input_label"       )
            self.assertEqual(task.label_schema["labels"]				,  UpperCamelCase__       )
            _a          =				task.align_with_features(Features({"input_label": ClassLabel(names=self.labels       )}       )       )
            self.assertEqual(task.label_schema["labels"]				,  ClassLabel(names=self.labels       )       )
  
  
  
  
  
  
  class __snake_case		(					_SCREAMING_SNAKE_CASE      ):
  
  
  
  
  
  
  
     """simple docstring"""
  
  
  
  
     def SCREAMING_SNAKE_CASE_      (		self							:Tuple       ):
            _a          =				DatasetInfo(task_templates=QuestionAnsweringExtractive()       )
            _a          =				Dataset.from_dict({k: [v] for k, v in SAMPLE_QUESTION_ANSWERING_EXTRACTIVE.items()}				,  info=UpperCamelCase__       )
            assert isinstance(dataset.info.task_templates				,  UpperCamelCase__       )
            assert len(dataset.info.task_templates       ) == 1
  
            def keep_task(UpperCamelCase__							:Any       ):
                   return x
  
            def dont_keep_task(UpperCamelCase__							:Union[str, Any]       ):
                   _a          =				deepcopy(UpperCamelCase__       )
                   _a          =				0
                   return out
  
            _a          =				dataset.map(UpperCamelCase__       )
            assert mapped_dataset.info.task_templates == dataset.info.task_templates
            # reload from cache
            _a          =				dataset.map(UpperCamelCase__       )
            assert mapped_dataset.info.task_templates == dataset.info.task_templates
  
            _a          =				dataset.map(UpperCamelCase__       )
            assert mapped_dataset.info.task_templates == []
            # reload from cache
            _a          =				dataset.map(UpperCamelCase__       )
            assert mapped_dataset.info.task_templates == []
  
  
  
  
     def SCREAMING_SNAKE_CASE_      (		self							:List[Any]       ):
            _a          =				Features({"text": Value("string"       ), "label": ClassLabel(names=("pos", "neg")       )}       )
            _a          =				TextClassification(text_column="text"				,  label_column="label"       )
            _a          =				DatasetInfo(features=UpperCamelCase__				,  task_templates=UpperCamelCase__       )
            _a          =				Dataset.from_dict({"text": ["A sentence."], "label": ["pos"]}				,  info=UpperCamelCase__       )
  
            def process(UpperCamelCase__							:Dict       ):
                   return example
  
            _a          =				dataset.remove_columns("label"       )
            _a          =				modified_dataset.map(UpperCamelCase__       )
            assert mapped_dataset.info.task_templates == []
  
style_context: 
  
  
  """simple docstring"""
  
  
  
  
  import warnings
  from contextlib import contextmanager
  
  from ...processing_utils import ProcessorMixin
  
  
  
  
  
  class __snake_case		(					_SCREAMING_SNAKE_CASE      ):
  
  
  
  
  
  
  
     """simple docstring"""
  
  
  
  
     lowerCAmelCase_				:   str     	=			'AutoFeatureExtractor'
     lowerCAmelCase_				:   List[Any]     	=			'Speech2Text2Tokenizer'
  
  
  
  
     def __init__(		self							:int				,  UpperCamelCase__							:List[str]				,  UpperCamelCase__							:Union[str, Any]       ):
            super().__init__(UpperCamelCase__				,  UpperCamelCase__       )
            _a          =				self.feature_extractor
            _a          =				False
  
  
  
  
     def __call__(		self							:List[str]				,  *UpperCamelCase__							:List[str]				,  **UpperCamelCase__							:Dict       ):
            # For backward compatibility
            if self._in_target_context_manager:
                   return self.current_processor(*UpperCamelCase__				,  **UpperCamelCase__       )
  
            if "raw_speech" in kwargs:
                   warnings.warn("Using `raw_speech` as a keyword argument is deprecated. Use `audio` instead."       )
                   _a          =				kwargs.pop("raw_speech"       )
            else:
                   _a          =				kwargs.pop("audio"				,  UpperCamelCase__       )
            _a          =				kwargs.pop("sampling_rate"				,  UpperCamelCase__       )
            _a          =				kwargs.pop("text"				,  UpperCamelCase__       )
            if len(UpperCamelCase__       ) > 0:
                   _a          =				args[0]
                   _a          =				args[1:]
  
            if audio is None and text is None:
                   raise ValueError("You need to specify either an `audio` or `text` input to process."       )
  
            if audio is not None:
                   _a          =				self.feature_extractor(UpperCamelCase__				,  *UpperCamelCase__				,  sampling_rate=UpperCamelCase__				,  **UpperCamelCase__       )
            if text is not None:
                   _a          =				self.tokenizer(UpperCamelCase__				,  **UpperCamelCase__       )
  
            if text is None:
                   return inputs
            elif audio is None:
                   return encodings
            else:
                   _a          =				encodings["input_ids"]
                   return inputs
  
  
  
  
     def SCREAMING_SNAKE_CASE_      (		self							:Union[str, Any]				,  *UpperCamelCase__							:int				,  **UpperCamelCase__							:Optional[Any]       ):
            return self.tokenizer.batch_decode(*UpperCamelCase__				,  **UpperCamelCase__       )
  
  
  
  
     def SCREAMING_SNAKE_CASE_      (		self							:Optional[Any]				,  *UpperCamelCase__							:List[Any]				,  **UpperCamelCase__							:List[Any]       ):
            return self.tokenizer.decode(*UpperCamelCase__				,  **UpperCamelCase__       )
  
  
  
  
     @contextmanager
     def SCREAMING_SNAKE_CASE_      (		self							:Dict       ):
            warnings.warn(
                "`as_target_processor` is deprecated and will be removed in v5 of Transformers. You can process your "
                "labels by using the argument `text` of the regular `__call__` method (either in the same call as "
                "your audio inputs, or in a separate call."       )
            _a          =				True
            _a          =				self.tokenizer
            yield
            _a          =				self.feature_extractor
            _a          =				False
  