

"""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


__UpperCAmelCase	=			{
    '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': [515]},
}
@pytest.mark.parametrize(
    """task_cls"""							,      [
        AudioClassification,
        AutomaticSpeechRecognition,
        ImageClassification,
        LanguageModeling,
        QuestionAnsweringExtractive,
        Summarization,
        TextClassification,
    ]							,      )
def 					lowerCAmelCase  (   __UpperCamelCase ):
 '''simple docstring'''





 UpperCAmelCase__   :					str   				=   task_cls()
 UpperCAmelCase__   :					Dict   				=   asdict(__UpperCamelCase )
 UpperCAmelCase__   :					Optional[int]   				=   task_template_from_dict(__UpperCamelCase )
 assert task == reloaded







class        __lowercase     :

  def 				__lowercase    (					self						:     List[str]      ):






   '''simple docstring'''
   UpperCAmelCase__   :					Union[str, Any]   				=   LanguageModeling(text_column="""input_text"""      )
   assert {"input_text": "text"} == task.column_mapping




  def 				__lowercase    (					self						:     Tuple      ):






   '''simple docstring'''
   UpperCAmelCase__   :					str   				=   Features({"""text""": Value("""string"""      )}      )
   UpperCAmelCase__   :					int   				=   {"""text_column""": """input_text"""}
   UpperCAmelCase__   :					Tuple   				=   LanguageModeling.from_dict(A      )
   assert "language-modeling" == task.task
   assert input_schema == task.input_schema







class        __lowercase     (      __lowerCamelCase   ):

  def 				__lowercase    (					self						:     Optional[Any]      ):






   '''simple docstring'''
   UpperCAmelCase__   :					Any   				=   sorted(["""pos""", """neg"""]      )

  def 				__lowercase    (					self						:     Any      ):






   '''simple docstring'''
   UpperCAmelCase__   :					Dict   				=   TextClassification(text_column="""input_text"""   ,label_column="""input_label"""      )
   self.assertDictEqual({"""input_text""": """text""", """input_label""": """labels"""}   ,task.column_mapping      )

  def 				__lowercase    (					self						:     Optional[Any]      ):






   '''simple docstring'''
   UpperCAmelCase__   :					Tuple   				=   Features({"""text""": Value("""string"""      )}      )
   # Labels are cast to tuple during `TextClassification.__post_init__`, so we do the same here
   UpperCAmelCase__   :					Tuple   				=   Features({"""labels""": ClassLabel}      )
   UpperCAmelCase__   :					Union[str, Any]   				=   {"""text_column""": """input_text""", """label_column""": """input_labels"""}
   UpperCAmelCase__   :					List[str]   				=   TextClassification.from_dict(A      )
   self.assertEqual("""text-classification"""   ,task.task      )
   self.assertEqual(A   ,task.input_schema      )
   self.assertEqual(A   ,task.label_schema      )




  def 				__lowercase    (					self						:     Tuple      ):






   '''simple docstring'''
   UpperCAmelCase__   :					Tuple   				=   TextClassification(text_column="""input_text"""   ,label_column="""input_label"""      )
   self.assertEqual(task.label_schema["""labels"""]   ,A      )
   UpperCAmelCase__   :					Union[str, Any]   				=   task.align_with_features(Features({"""input_label""": ClassLabel(names=self.labels      )}      )      )
   self.assertEqual(task.label_schema["""labels"""]   ,ClassLabel(names=self.labels      )      )







class        __lowercase     (      __lowerCamelCase   ):

  def 				__lowercase    (					self						:     Optional[Any]      ):






   '''simple docstring'''
   UpperCAmelCase__   :					int   				=   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 				__lowercase    (					self						:     Optional[Any]      ):






   '''simple docstring'''
   UpperCAmelCase__   :					List[str]   				=   Features({"""question""": Value("""string"""      ), """context""": Value("""string"""      )}      )
   UpperCAmelCase__   :					Union[str, Any]   				=   Features(
       {
           """answers""": Sequence(
               {
                   """text""": Value("""string"""      ),
                   """answer_start""": Value("""int32"""      ),
               }      )
       }      )
   UpperCAmelCase__   :					int   				=   {
       """context_column""": """input_input_context""",
       """question_column""": """input_question""",
       """answers_column""": """input_answers""",
   }
   UpperCAmelCase__   :					List[Any]   				=   QuestionAnsweringExtractive.from_dict(A      )
   self.assertEqual("""question-answering-extractive"""   ,task.task      )
   self.assertEqual(A   ,task.input_schema      )
   self.assertEqual(A   ,task.label_schema      )







class        __lowercase     (      __lowerCamelCase   ):

  def 				__lowercase    (					self						:     List[Any]      ):






   '''simple docstring'''
   UpperCAmelCase__   :					Tuple   				=   Summarization(text_column="""input_text"""   ,summary_column="""input_summary"""      )
   self.assertDictEqual({"""input_text""": """text""", """input_summary""": """summary"""}   ,task.column_mapping      )




  def 				__lowercase    (					self						:     Dict      ):






   '''simple docstring'''
   UpperCAmelCase__   :					Optional[Any]   				=   Features({"""text""": Value("""string"""      )}      )
   UpperCAmelCase__   :					List[str]   				=   Features({"""summary""": Value("""string"""      )}      )
   UpperCAmelCase__   :					Dict   				=   {"""text_column""": """input_text""", """summary_column""": """input_summary"""}
   UpperCAmelCase__   :					List[Any]   				=   Summarization.from_dict(A      )
   self.assertEqual("""summarization"""   ,task.task      )
   self.assertEqual(A   ,task.input_schema      )
   self.assertEqual(A   ,task.label_schema      )







class        __lowercase     (      __lowerCamelCase   ):

  def 				__lowercase    (					self						:     Optional[Any]      ):






   '''simple docstring'''
   UpperCAmelCase__   :					Union[str, Any]   				=   AutomaticSpeechRecognition(audio_column="""input_audio"""   ,transcription_column="""input_transcription"""      )
   self.assertDictEqual({"""input_audio""": """audio""", """input_transcription""": """transcription"""}   ,task.column_mapping      )




  def 				__lowercase    (					self						:     str      ):






   '''simple docstring'''
   UpperCAmelCase__   :					str   				=   Features({"""audio""": Audio()}      )
   UpperCAmelCase__   :					Any   				=   Features({"""transcription""": Value("""string"""      )}      )
   UpperCAmelCase__   :					Tuple   				=   {
       """audio_column""": """input_audio""",
       """transcription_column""": """input_transcription""",
   }
   UpperCAmelCase__   :					Optional[Any]   				=   AutomaticSpeechRecognition.from_dict(A      )
   self.assertEqual("""automatic-speech-recognition"""   ,task.task      )
   self.assertEqual(A   ,task.input_schema      )
   self.assertEqual(A   ,task.label_schema      )







class        __lowercase     (      __lowerCamelCase   ):

  def 				__lowercase    (					self						:     Optional[Any]      ):






   '''simple docstring'''
   UpperCAmelCase__   :					Dict   				=   sorted(["""pos""", """neg"""]      )

  def 				__lowercase    (					self						:     int      ):






   '''simple docstring'''
   UpperCAmelCase__   :					Union[str, Any]   				=   AudioClassification(audio_column="""input_audio"""   ,label_column="""input_label"""      )
   self.assertDictEqual({"""input_audio""": """audio""", """input_label""": """labels"""}   ,task.column_mapping      )

  def 				__lowercase    (					self						:     Optional[Any]      ):






   '''simple docstring'''
   UpperCAmelCase__   :					Optional[int]   				=   Features({"""audio""": Audio()}      )
   UpperCAmelCase__   :					str   				=   Features({"""labels""": ClassLabel}      )
   UpperCAmelCase__   :					List[Any]   				=   {
       """audio_column""": """input_image""",
       """label_column""": """input_label""",
   }
   UpperCAmelCase__   :					List[Any]   				=   AudioClassification.from_dict(A      )
   self.assertEqual("""audio-classification"""   ,task.task      )
   self.assertEqual(A   ,task.input_schema      )
   self.assertEqual(A   ,task.label_schema      )




  def 				__lowercase    (					self						:     Union[str, Any]      ):






   '''simple docstring'''
   UpperCAmelCase__   :					Union[str, Any]   				=   AudioClassification(audio_column="""input_audio"""   ,label_column="""input_label"""      )
   self.assertEqual(task.label_schema["""labels"""]   ,A      )
   UpperCAmelCase__   :					str   				=   task.align_with_features(Features({"""input_label""": ClassLabel(names=self.labels      )}      )      )
   self.assertEqual(task.label_schema["""labels"""]   ,ClassLabel(names=self.labels      )      )







class        __lowercase     (      __lowerCamelCase   ):

  def 				__lowercase    (					self						:     Any      ):






   '''simple docstring'''
   UpperCAmelCase__   :					List[str]   				=   sorted(["""pos""", """neg"""]      )

  def 				__lowercase    (					self						:     Union[str, Any]      ):






   '''simple docstring'''
   UpperCAmelCase__   :					Union[str, Any]   				=   ImageClassification(image_column="""input_image"""   ,label_column="""input_label"""      )
   self.assertDictEqual({"""input_image""": """image""", """input_label""": """labels"""}   ,task.column_mapping      )

  def 				__lowercase    (					self						:     List[str]      ):






   '''simple docstring'''
   UpperCAmelCase__   :					Any   				=   Features({"""image""": Image()}      )
   UpperCAmelCase__   :					Dict   				=   Features({"""labels""": ClassLabel}      )
   UpperCAmelCase__   :					List[str]   				=   {
       """image_column""": """input_image""",
       """label_column""": """input_label""",
   }
   UpperCAmelCase__   :					Dict   				=   ImageClassification.from_dict(A      )
   self.assertEqual("""image-classification"""   ,task.task      )
   self.assertEqual(A   ,task.input_schema      )
   self.assertEqual(A   ,task.label_schema      )




  def 				__lowercase    (					self						:     Optional[Any]      ):






   '''simple docstring'''
   UpperCAmelCase__   :					Optional[Any]   				=   ImageClassification(image_column="""input_image"""   ,label_column="""input_label"""      )
   self.assertEqual(task.label_schema["""labels"""]   ,A      )
   UpperCAmelCase__   :					Tuple   				=   task.align_with_features(Features({"""input_label""": ClassLabel(names=self.labels      )}      )      )
   self.assertEqual(task.label_schema["""labels"""]   ,ClassLabel(names=self.labels      )      )







class        __lowercase     (      __lowerCamelCase   ):

  def 				__lowercase    (					self						:     Tuple      ):






   '''simple docstring'''
   UpperCAmelCase__   :					Union[str, Any]   				=   DatasetInfo(task_templates=QuestionAnsweringExtractive()      )
   UpperCAmelCase__   :					Any   				=   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						:     Dict      ):
    return x

   def dont_keep_task(A						:     List[Any]      ):
    UpperCAmelCase__   :					str   				=   deepcopy(A      )
    UpperCAmelCase__   :					List[Any]   				=   0
    return out

   UpperCAmelCase__   :					Union[str, Any]   				=   dataset.map(A      )
   assert mapped_dataset.info.task_templates == dataset.info.task_templates
   # reload from cache
   UpperCAmelCase__   :					Optional[Any]   				=   dataset.map(A      )
   assert mapped_dataset.info.task_templates == dataset.info.task_templates

   UpperCAmelCase__   :					Union[str, Any]   				=   dataset.map(A      )
   assert mapped_dataset.info.task_templates == []
   # reload from cache
   UpperCAmelCase__   :					Dict   				=   dataset.map(A      )
   assert mapped_dataset.info.task_templates == []




  def 				__lowercase    (					self						:     Tuple      ):






   '''simple docstring'''
   UpperCAmelCase__   :					Union[str, Any]   				=   Features({"""text""": Value("""string"""      ), """label""": ClassLabel(names=("""pos""", """neg""")      )}      )
   UpperCAmelCase__   :					Optional[Any]   				=   TextClassification(text_column="""text"""   ,label_column="""label"""      )
   UpperCAmelCase__   :					Optional[int]   				=   DatasetInfo(features=A   ,task_templates=A      )
   UpperCAmelCase__   :					List[str]   				=   Dataset.from_dict({"""text""": ["""A sentence."""], """label""": ["""pos"""]}   ,info=A      )

   def process(A						:     int      ):
    return example

   UpperCAmelCase__   :					int   				=   dataset.remove_columns("""label"""      )
   UpperCAmelCase__   :					Optional[Any]   				=   modified_dataset.map(A      )
   assert mapped_dataset.info.task_templates == []








"""simple docstring"""




from math import factorial
def 					lowerCAmelCase  (   __UpperCamelCase							,      __UpperCamelCase ):
 '''simple docstring'''





 return factorial(__UpperCamelCase ) / (factorial(__UpperCamelCase ) * factorial(n - r ))
def 					lowerCAmelCase  (   ):
 '''simple docstring'''





 UpperCAmelCase__   :					Any   				=   0

 for i in range(1							,      101 ):
  for j in range(1							,      i + 1 ):
   if combinations(__UpperCamelCase							,      __UpperCamelCase ) > 1e6:
    total += 1
 return total


if __name__ == "__main__":
      print(solution())





