


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


__magic_name__          =							{
    '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__   :int    ):
			__lowerCamelCase        =			task_cls()
			__lowerCamelCase        =			asdict(UpperCAmelCase_    )
			__lowerCamelCase        =			task_template_from_dict(UpperCAmelCase_    )
			assert task == reloaded




class  __snake_case      :




							def      __a      (    self:						Dict      ):
										__lowerCamelCase        =			LanguageModeling(text_column="""input_text"""      )
										assert {"input_text": "text"} == task.column_mapping




							def      __a      (    self:						Tuple      ):
										__lowerCamelCase        =			Features({"""text""": Value("""string"""      )}      )
										__lowerCamelCase        =			{'''text_column''': '''input_text'''}
										__lowerCamelCase        =			LanguageModeling.from_dict(A_      )
										assert "language-modeling" == task.task
										assert input_schema == task.input_schema




class  __snake_case      (A_     ):




							def      __a      (    self:						Optional[Any]      ):
										__lowerCamelCase        =			sorted(["""pos""", """neg"""]      )




							def      __a      (    self:						List[Any]      ):
										__lowerCamelCase        =			TextClassification(text_column="""input_text"""    ,       label_column="""input_label"""      )
										self.assertDictEqual({"""input_text""": """text""", """input_label""": """labels"""}    ,       task.column_mapping      )




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




							def      __a      (    self:						List[Any]      ):
										__lowerCamelCase        =			TextClassification(text_column="""input_text"""    ,       label_column="""input_label"""      )
										self.assertEqual(task.label_schema["""labels"""]    ,       A_      )
										__lowerCamelCase        =			task.align_with_features(Features({"""input_label""": ClassLabel(names=self.labels      )}      )      )
										self.assertEqual(task.label_schema["""labels"""]    ,       ClassLabel(names=self.labels      )      )




class  __snake_case      (A_     ):




							def      __a      (    self:						str      ):
										__lowerCamelCase        =			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      __a      (    self:						Dict      ):
										__lowerCamelCase        =			Features({"""question""": Value("""string"""      ), """context""": Value("""string"""      )}      )
										__lowerCamelCase        =			Features(
										    {
										        """answers""": Sequence(
										            {
										                """text""": Value("""string"""      ),
										                """answer_start""": Value("""int32"""      ),
										            }      )
										    }      )
										__lowerCamelCase        =			{
										    '''context_column''': '''input_input_context''',
										    '''question_column''': '''input_question''',
										    '''answers_column''': '''input_answers''',
										}
										__lowerCamelCase        =			QuestionAnsweringExtractive.from_dict(A_      )
										self.assertEqual("""question-answering-extractive"""    ,       task.task      )
										self.assertEqual(A_    ,       task.input_schema      )
										self.assertEqual(A_    ,       task.label_schema      )




class  __snake_case      (A_     ):




							def      __a      (    self:						Optional[Any]      ):
										__lowerCamelCase        =			Summarization(text_column="""input_text"""    ,       summary_column="""input_summary"""      )
										self.assertDictEqual({"""input_text""": """text""", """input_summary""": """summary"""}    ,       task.column_mapping      )




							def      __a      (    self:						Tuple      ):
										__lowerCamelCase        =			Features({"""text""": Value("""string"""      )}      )
										__lowerCamelCase        =			Features({"""summary""": Value("""string"""      )}      )
										__lowerCamelCase        =			{'''text_column''': '''input_text''', '''summary_column''': '''input_summary'''}
										__lowerCamelCase        =			Summarization.from_dict(A_      )
										self.assertEqual("""summarization"""    ,       task.task      )
										self.assertEqual(A_    ,       task.input_schema      )
										self.assertEqual(A_    ,       task.label_schema      )




class  __snake_case      (A_     ):




							def      __a      (    self:						List[str]      ):
										__lowerCamelCase        =			AutomaticSpeechRecognition(audio_column="""input_audio"""    ,       transcription_column="""input_transcription"""      )
										self.assertDictEqual({"""input_audio""": """audio""", """input_transcription""": """transcription"""}    ,       task.column_mapping      )




							def      __a      (    self:						Dict      ):
										__lowerCamelCase        =			Features({"""audio""": Audio()}      )
										__lowerCamelCase        =			Features({"""transcription""": Value("""string"""      )}      )
										__lowerCamelCase        =			{
										    '''audio_column''': '''input_audio''',
										    '''transcription_column''': '''input_transcription''',
										}
										__lowerCamelCase        =			AutomaticSpeechRecognition.from_dict(A_      )
										self.assertEqual("""automatic-speech-recognition"""    ,       task.task      )
										self.assertEqual(A_    ,       task.input_schema      )
										self.assertEqual(A_    ,       task.label_schema      )




class  __snake_case      (A_     ):




							def      __a      (    self:						Tuple      ):
										__lowerCamelCase        =			sorted(["""pos""", """neg"""]      )




							def      __a      (    self:						List[Any]      ):
										__lowerCamelCase        =			AudioClassification(audio_column="""input_audio"""    ,       label_column="""input_label"""      )
										self.assertDictEqual({"""input_audio""": """audio""", """input_label""": """labels"""}    ,       task.column_mapping      )




							def      __a      (    self:						Optional[Any]      ):
										__lowerCamelCase        =			Features({"""audio""": Audio()}      )
										__lowerCamelCase        =			Features({"""labels""": ClassLabel}      )
										__lowerCamelCase        =			{
										    '''audio_column''': '''input_image''',
										    '''label_column''': '''input_label''',
										}
										__lowerCamelCase        =			AudioClassification.from_dict(A_      )
										self.assertEqual("""audio-classification"""    ,       task.task      )
										self.assertEqual(A_    ,       task.input_schema      )
										self.assertEqual(A_    ,       task.label_schema      )




							def      __a      (    self:						str      ):
										__lowerCamelCase        =			AudioClassification(audio_column="""input_audio"""    ,       label_column="""input_label"""      )
										self.assertEqual(task.label_schema["""labels"""]    ,       A_      )
										__lowerCamelCase        =			task.align_with_features(Features({"""input_label""": ClassLabel(names=self.labels      )}      )      )
										self.assertEqual(task.label_schema["""labels"""]    ,       ClassLabel(names=self.labels      )      )




class  __snake_case      (A_     ):




							def      __a      (    self:						Union[str, Any]      ):
										__lowerCamelCase        =			sorted(["""pos""", """neg"""]      )




							def      __a      (    self:						Optional[Any]      ):
										__lowerCamelCase        =			ImageClassification(image_column="""input_image"""    ,       label_column="""input_label"""      )
										self.assertDictEqual({"""input_image""": """image""", """input_label""": """labels"""}    ,       task.column_mapping      )




							def      __a      (    self:						Union[str, Any]      ):
										__lowerCamelCase        =			Features({"""image""": Image()}      )
										__lowerCamelCase        =			Features({"""labels""": ClassLabel}      )
										__lowerCamelCase        =			{
										    '''image_column''': '''input_image''',
										    '''label_column''': '''input_label''',
										}
										__lowerCamelCase        =			ImageClassification.from_dict(A_      )
										self.assertEqual("""image-classification"""    ,       task.task      )
										self.assertEqual(A_    ,       task.input_schema      )
										self.assertEqual(A_    ,       task.label_schema      )




							def      __a      (    self:						List[Any]      ):
										__lowerCamelCase        =			ImageClassification(image_column="""input_image"""    ,       label_column="""input_label"""      )
										self.assertEqual(task.label_schema["""labels"""]    ,       A_      )
										__lowerCamelCase        =			task.align_with_features(Features({"""input_label""": ClassLabel(names=self.labels      )}      )      )
										self.assertEqual(task.label_schema["""labels"""]    ,       ClassLabel(names=self.labels      )      )




class  __snake_case      (A_     ):




							def      __a      (    self:						Tuple      ):
										__lowerCamelCase        =			DatasetInfo(task_templates=QuestionAnsweringExtractive()      )
										__lowerCamelCase        =			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]      ):
													__lowerCamelCase        =			deepcopy(A_      )
													__lowerCamelCase        =			0
													return out

										__lowerCamelCase        =			dataset.map(A_      )
										assert mapped_dataset.info.task_templates == dataset.info.task_templates
										# reload from cache
										__lowerCamelCase        =			dataset.map(A_      )
										assert mapped_dataset.info.task_templates == dataset.info.task_templates

										__lowerCamelCase        =			dataset.map(A_      )
										assert mapped_dataset.info.task_templates == []
										# reload from cache
										__lowerCamelCase        =			dataset.map(A_      )
										assert mapped_dataset.info.task_templates == []




							def      __a      (    self:						str      ):
										__lowerCamelCase        =			Features({"""text""": Value("""string"""      ), """label""": ClassLabel(names=("""pos""", """neg""")      )}      )
										__lowerCamelCase        =			TextClassification(text_column="""text"""    ,       label_column="""label"""      )
										__lowerCamelCase        =			DatasetInfo(features=A_    ,       task_templates=A_      )
										__lowerCamelCase        =			Dataset.from_dict({"""text""": ["""A sentence."""], """label""": ["""pos"""]}    ,       info=A_      )

										def process(A_:						str      ):
													return example

										__lowerCamelCase        =			dataset.remove_columns("""label"""      )
										__lowerCamelCase        =			modified_dataset.map(A_      )
										assert mapped_dataset.info.task_templates == []








"""simple docstring"""




import os





def 			a_   (  ):
			__lowerCamelCase        =			os.path.dirname(os.path.realpath(lowercase__    )    )
			__lowerCamelCase        =			os.path.join(lowercase__, """triangle.txt"""    )

			with open(lowercase__    ) as in_file:
						__lowerCamelCase        =			[[int(lowercase__    ) for i in line.split()] for line in in_file]

			while len(lowercase__    ) != 1:
						__lowerCamelCase        =			triangle.pop()
						__lowerCamelCase        =			triangle[-1]
						for j in range(len(lowercase__    ) - 1    ):
									curr_row[j] += max(last_row[j], last_row[j + 1]    )
			return triangle[0][0]


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




