code: 
  
  
  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
  
  
  __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_1_5]},
  }
  
  
  
  
  
  
  @pytest.mark.parametrize(
      'task_cls'				,     [
          AudioClassification,
          AutomaticSpeechRecognition,
          ImageClassification,
          LanguageModeling,
          QuestionAnsweringExtractive,
          Summarization,
          TextClassification,
      ]				,     )
  def 		_A		(		_lowercase   )				->   Any:
  
  
       """simple docstring"""
  
  
       __UpperCamelCase   = task_cls()
       __UpperCamelCase   = asdict(UpperCAmelCase_   )
       __UpperCamelCase   = task_template_from_dict(UpperCAmelCase_   )
       assert task == reloaded
  
  
  
  class   __lowerCamelCase :
  
  
  
  
  
  
  
         def 		snake_case_  ( self:   Dict				):
  
  
  
  
  
  
              '''simple docstring'''
  
  
  
  
              __UpperCamelCase   = LanguageModeling(text_column='input_text'				)
              assert {"input_text": "text"} == task.column_mapping
  
  
  
  
  
  
  
         def 		snake_case_  ( self:   Tuple				):
  
  
  
  
  
  
              '''simple docstring'''
  
  
  
  
              __UpperCamelCase   = Features({'text': Value('string'				)}				)
              __UpperCamelCase   = {'''text_column''': '''input_text'''}
              __UpperCamelCase   = LanguageModeling.from_dict(A_				)
              assert "language-modeling" == task.task
              assert input_schema == task.input_schema
  
  
  
  class   __lowerCamelCase (A_	):
  
  
  
  
  
  
  
         def 		snake_case_  ( self:   Optional[Any]				):
  
  
  
  
  
  
              '''simple docstring'''
  
  
  
  
              __UpperCamelCase   = sorted(['pos', 'neg']				)
  
  
  
  
  
  
  
         def 		snake_case_  ( self:   List[Any]				):
  
  
  
  
  
  
              '''simple docstring'''
  
  
  
  
              __UpperCamelCase   = TextClassification(text_column='input_text',label_column='input_label'				)
              self.assertDictEqual({'input_text': 'text', 'input_label': 'labels'},task.column_mapping				)
  
  
  
  
  
  
  
         def 		snake_case_  ( self:   Union[str, Any]				):
  
  
  
  
  
  
              '''simple docstring'''
  
  
  
  
              __UpperCamelCase   = Features({'text': Value('string'				)}				)
              # Labels are cast to tuple during `TextClassification.__post_init__`, so we do the same here
              __UpperCamelCase   = Features({'labels': ClassLabel}				)
              __UpperCamelCase   = {'''text_column''': '''input_text''', '''label_column''': '''input_labels'''}
              __UpperCamelCase   = TextClassification.from_dict(A_				)
              self.assertEqual('text-classification',task.task				)
              self.assertEqual(A_,task.input_schema				)
              self.assertEqual(A_,task.label_schema				)
  
  
  
  
  
  
  
         def 		snake_case_  ( self:   List[Any]				):
  
  
  
  
  
  
              '''simple docstring'''
  
  
  
  
              __UpperCamelCase   = TextClassification(text_column='input_text',label_column='input_label'				)
              self.assertEqual(task.label_schema['labels'],A_				)
              __UpperCamelCase   = task.align_with_features(Features({'input_label': ClassLabel(names=self.labels				)}				)				)
              self.assertEqual(task.label_schema['labels'],ClassLabel(names=self.labels				)				)
  
  
  
  class   __lowerCamelCase (A_	):
  
  
  
  
  
  
  
         def 		snake_case_  ( self:   str				):
  
  
  
  
  
  
              '''simple docstring'''
  
  
  
  
              __UpperCamelCase   = 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 		snake_case_  ( self:   Dict				):
  
  
  
  
  
  
              '''simple docstring'''
  
  
  
  
              __UpperCamelCase   = Features({'question': Value('string'				), 'context': Value('string'				)}				)
              __UpperCamelCase   = Features(
                  {
                      'answers': Sequence(
                          {
                              'text': Value('string'				),
                              'answer_start': Value('int32'				),
                          }				)
                  }				)
              __UpperCamelCase   = {
                  '''context_column''': '''input_input_context''',
                  '''question_column''': '''input_question''',
                  '''answers_column''': '''input_answers''',
              }
              __UpperCamelCase   = QuestionAnsweringExtractive.from_dict(A_				)
              self.assertEqual('question-answering-extractive',task.task				)
              self.assertEqual(A_,task.input_schema				)
              self.assertEqual(A_,task.label_schema				)
  
  
  
  class   __lowerCamelCase (A_	):
  
  
  
  
  
  
  
         def 		snake_case_  ( self:   Optional[Any]				):
  
  
  
  
  
  
              '''simple docstring'''
  
  
  
  
              __UpperCamelCase   = Summarization(text_column='input_text',summary_column='input_summary'				)
              self.assertDictEqual({'input_text': 'text', 'input_summary': 'summary'},task.column_mapping				)
  
  
  
  
  
  
  
         def 		snake_case_  ( self:   Tuple				):
  
  
  
  
  
  
              '''simple docstring'''
  
  
  
  
              __UpperCamelCase   = Features({'text': Value('string'				)}				)
              __UpperCamelCase   = Features({'summary': Value('string'				)}				)
              __UpperCamelCase   = {'''text_column''': '''input_text''', '''summary_column''': '''input_summary'''}
              __UpperCamelCase   = Summarization.from_dict(A_				)
              self.assertEqual('summarization',task.task				)
              self.assertEqual(A_,task.input_schema				)
              self.assertEqual(A_,task.label_schema				)
  
  
  
  class   __lowerCamelCase (A_	):
  
  
  
  
  
  
  
         def 		snake_case_  ( self:   List[str]				):
  
  
  
  
  
  
              '''simple docstring'''
  
  
  
  
              __UpperCamelCase   = AutomaticSpeechRecognition(audio_column='input_audio',transcription_column='input_transcription'				)
              self.assertDictEqual({'input_audio': 'audio', 'input_transcription': 'transcription'},task.column_mapping				)
  
  
  
  
  
  
  
         def 		snake_case_  ( self:   Dict				):
  
  
  
  
  
  
              '''simple docstring'''
  
  
  
  
              __UpperCamelCase   = Features({'audio': Audio()}				)
              __UpperCamelCase   = Features({'transcription': Value('string'				)}				)
              __UpperCamelCase   = {
                  '''audio_column''': '''input_audio''',
                  '''transcription_column''': '''input_transcription''',
              }
              __UpperCamelCase   = AutomaticSpeechRecognition.from_dict(A_				)
              self.assertEqual('automatic-speech-recognition',task.task				)
              self.assertEqual(A_,task.input_schema				)
              self.assertEqual(A_,task.label_schema				)
  
  
  
  class   __lowerCamelCase (A_	):
  
  
  
  
  
  
  
         def 		snake_case_  ( self:   Tuple				):
  
  
  
  
  
  
              '''simple docstring'''
  
  
  
  
              __UpperCamelCase   = sorted(['pos', 'neg']				)
  
  
  
  
  
  
  
         def 		snake_case_  ( self:   List[Any]				):
  
  
  
  
  
  
              '''simple docstring'''
  
  
  
  
              __UpperCamelCase   = AudioClassification(audio_column='input_audio',label_column='input_label'				)
              self.assertDictEqual({'input_audio': 'audio', 'input_label': 'labels'},task.column_mapping				)
  
  
  
  
  
  
  
         def 		snake_case_  ( self:   Optional[Any]				):
  
  
  
  
  
  
              '''simple docstring'''
  
  
  
  
              __UpperCamelCase   = Features({'audio': Audio()}				)
              __UpperCamelCase   = Features({'labels': ClassLabel}				)
              __UpperCamelCase   = {
                  '''audio_column''': '''input_image''',
                  '''label_column''': '''input_label''',
              }
              __UpperCamelCase   = AudioClassification.from_dict(A_				)
              self.assertEqual('audio-classification',task.task				)
              self.assertEqual(A_,task.input_schema				)
              self.assertEqual(A_,task.label_schema				)
  
  
  
  
  
  
  
         def 		snake_case_  ( self:   str				):
  
  
  
  
  
  
              '''simple docstring'''
  
  
  
  
              __UpperCamelCase   = AudioClassification(audio_column='input_audio',label_column='input_label'				)
              self.assertEqual(task.label_schema['labels'],A_				)
              __UpperCamelCase   = task.align_with_features(Features({'input_label': ClassLabel(names=self.labels				)}				)				)
              self.assertEqual(task.label_schema['labels'],ClassLabel(names=self.labels				)				)
  
  
  
  class   __lowerCamelCase (A_	):
  
  
  
  
  
  
  
         def 		snake_case_  ( self:   Union[str, Any]				):
  
  
  
  
  
  
              '''simple docstring'''
  
  
  
  
              __UpperCamelCase   = sorted(['pos', 'neg']				)
  
  
  
  
  
  
  
         def 		snake_case_  ( self:   Optional[Any]				):
  
  
  
  
  
  
              '''simple docstring'''
  
  
  
  
              __UpperCamelCase   = ImageClassification(image_column='input_image',label_column='input_label'				)
              self.assertDictEqual({'input_image': 'image', 'input_label': 'labels'},task.column_mapping				)
  
  
  
  
  
  
  
         def 		snake_case_  ( self:   Union[str, Any]				):
  
  
  
  
  
  
              '''simple docstring'''
  
  
  
  
              __UpperCamelCase   = Features({'image': Image()}				)
              __UpperCamelCase   = Features({'labels': ClassLabel}				)
              __UpperCamelCase   = {
                  '''image_column''': '''input_image''',
                  '''label_column''': '''input_label''',
              }
              __UpperCamelCase   = ImageClassification.from_dict(A_				)
              self.assertEqual('image-classification',task.task				)
              self.assertEqual(A_,task.input_schema				)
              self.assertEqual(A_,task.label_schema				)
  
  
  
  
  
  
  
         def 		snake_case_  ( self:   List[Any]				):
  
  
  
  
  
  
              '''simple docstring'''
  
  
  
  
              __UpperCamelCase   = ImageClassification(image_column='input_image',label_column='input_label'				)
              self.assertEqual(task.label_schema['labels'],A_				)
              __UpperCamelCase   = task.align_with_features(Features({'input_label': ClassLabel(names=self.labels				)}				)				)
              self.assertEqual(task.label_schema['labels'],ClassLabel(names=self.labels				)				)
  
  
  
  class   __lowerCamelCase (A_	):
  
  
  
  
  
  
  
         def 		snake_case_  ( self:   Tuple				):
  
  
  
  
  
  
              '''simple docstring'''
  
  
  
  
              __UpperCamelCase   = DatasetInfo(task_templates=QuestionAnsweringExtractive()				)
              __UpperCamelCase   = Dataset.from_dict({k: [v] for k, v in SAMPLE_QUESTION_ANSWERING_EXTRACTIVE.items()},info=A_				)
              assert isinstance(dataset.info.task_templates,A_				)
              assert len(dataset.info.task_templates				) == 1
  
              def keep_task(A_:   List[str]				):
                   return x
  
              def dont_keep_task(A_:   Optional[int]				):
                   __UpperCamelCase   = deepcopy(A_				)
                   __UpperCamelCase   = 0
                   return out
  
              __UpperCamelCase   = dataset.map(A_				)
              assert mapped_dataset.info.task_templates == dataset.info.task_templates
              # reload from cache
              __UpperCamelCase   = dataset.map(A_				)
              assert mapped_dataset.info.task_templates == dataset.info.task_templates
  
              __UpperCamelCase   = dataset.map(A_				)
              assert mapped_dataset.info.task_templates == []
              # reload from cache
              __UpperCamelCase   = dataset.map(A_				)
              assert mapped_dataset.info.task_templates == []
  
  
  
  
  
  
  
         def 		snake_case_  ( self:   str				):
  
  
  
  
  
  
              '''simple docstring'''
  
  
  
  
              __UpperCamelCase   = Features({'text': Value('string'				), 'label': ClassLabel(names=('pos', 'neg')				)}				)
              __UpperCamelCase   = TextClassification(text_column='text',label_column='label'				)
              __UpperCamelCase   = DatasetInfo(features=A_,task_templates=A_				)
              __UpperCamelCase   = Dataset.from_dict({'text': ['A sentence.'], 'label': ['pos']},info=A_				)
  
              def process(A_:   str				):
                   return example
  
              __UpperCamelCase   = dataset.remove_columns('label'				)
              __UpperCamelCase   = modified_dataset.map(A_				)
              assert mapped_dataset.info.task_templates == []
  
style_context: 
  
  
  import warnings
  from collections.abc import Callable
  from typing import Any
  
  import numpy
  from matplotlib import pyplot
  
  __snake_case             =	0.25 + 0.0j
  __snake_case             =	-0.4 + 0.6j
  __snake_case             =	-0.1 + 0.6_51j
  __snake_case             =	-2.0
  __snake_case             =	5_6
  __snake_case             =	2.0
  __snake_case             =	6_6_6
  
  
  
  
  
  
  def 		_A		(		_lowercase				,     _lowercase   )				->   numpy.ndarray:
  
  
       """simple docstring"""
  
  
       return numpy.exp(_lowercase   ) + c_parameter
  
  
  
  
  
  
  def 		_A		(		_lowercase				,     _lowercase   )				->   numpy.ndarray:
  
  
       """simple docstring"""
  
  
       return z_values * z_values + c_parameter
  
  
  
  
  
  
  def 		_A		(		_lowercase				,     _lowercase   )				->   numpy.ndarray:
  
  
       """simple docstring"""
  
  
       __UpperCamelCase   = numpy.linspace(-window_size				,     _lowercase				,     _lowercase   )
       __UpperCamelCase   = x.reshape((nb_pixels, 1)   )
       __UpperCamelCase   = numpy.linspace(-window_size				,     _lowercase				,     _lowercase   )
       __UpperCamelCase   = y.reshape((1, nb_pixels)   )
       return x + 1.0J * y
  
  
  
  
  
  
  def 		_A		(		_lowercase				,     _lowercase				,     _lowercase				,     _lowercase				,     _lowercase = None				,     )				->   numpy.ndarray:
  
  
       """simple docstring"""
  
  
       __UpperCamelCase   = z_a.astype('complex64'   )
       for _ in range(_lowercase   ):
            __UpperCamelCase   = eval_function(_lowercase				,     _lowercase   )
            if infinity is not None:
                 numpy.nan_to_num(_lowercase				,     copy=_lowercase				,     nan=_lowercase   )
                 __UpperCamelCase   = infinity
       return z_n
  
  
  
  
  
  
  def 		_A		(		_lowercase				,     _lowercase				,     _lowercase				,     _lowercase				,     )				->   None:
  
  
       """simple docstring"""
  
  
       __UpperCamelCase   = (abs(_lowercase   )).transpose()
       __UpperCamelCase   = abs_z_final[::-1, :]
       pyplot.matshow(abs_z_final < escape_radius   )
       pyplot.title(f'''Julia set of ${function_label}$, $c={function_params}$'''   )
       pyplot.show()
  
  
  
  
  
  
  def 		_A		(		)				->   None:
  
  
       """simple docstring"""
  
  
       warnings.filterwarnings(
           'ignore'				,     category=_lowercase				,     message='overflow encountered in multiply'   )
       warnings.filterwarnings(
           'ignore'				,     category=_lowercase				,     message='invalid value encountered in multiply'				,     )
       warnings.filterwarnings(
           'ignore'				,     category=_lowercase				,     message='overflow encountered in absolute'   )
       warnings.filterwarnings(
           'ignore'				,     category=_lowercase				,     message='overflow encountered in exp'   )
  
  
  if __name__ == "__main__":
      __snake_case             =	prepare_grid(window_size, nb_pixels)
  
      ignore_overflow_warnings()  # See file header for explanations
  
      __snake_case             =	2_4
      __snake_case             =	2 * abs(c_cauliflower) + 1
      __snake_case             =	iterate_function(
          eval_quadratic_polynomial,
          c_cauliflower,
          nb_iterations,
          z_a,
          infinity=1.1 * escape_radius,
      )
      show_results('''z^2+c''', c_cauliflower, escape_radius, z_final)
  
      __snake_case             =	6_4
      __snake_case             =	2 * abs(c_polynomial_a) + 1
      __snake_case             =	iterate_function(
          eval_quadratic_polynomial,
          c_polynomial_a,
          nb_iterations,
          z_a,
          infinity=1.1 * escape_radius,
      )
      show_results('''z^2+c''', c_polynomial_a, escape_radius, z_final)
  
      __snake_case             =	1_6_1
      __snake_case             =	2 * abs(c_polynomial_a) + 1
      __snake_case             =	iterate_function(
          eval_quadratic_polynomial,
          c_polynomial_a,
          nb_iterations,
          z_a,
          infinity=1.1 * escape_radius,
      )
      show_results('''z^2+c''', c_polynomial_a, escape_radius, z_final)
  
      __snake_case             =	1_2
      __snake_case             =	10_000.0
      __snake_case             =	iterate_function(
          eval_exponential,
          c_exponential,
          nb_iterations,
          z_a + 2,
          infinity=1.0e10,
      )
      show_results('''e^z+c''', c_exponential, escape_radius, z_final)
  
  
  