
'''simple docstring'''



from unittest import TestCase

from datasets import Sequence, Value
from datasets.arrow_dataset import Dataset

class  _a					(SCREAMING_SNAKE_CASE__):





       """simple docstring"""




       def 							UpperCamelCase					(				self   )     ->      Any:
          return [
              {"col_1": 3, "col_2": "a"},
              {"col_1": 2, "col_2": "b"},
              {"col_1": 1, "col_2": "c"},
              {"col_1": 0, "col_2": "d"},
          ]






       def 							UpperCamelCase					(				self   )     ->      Tuple:
          _SCREAMING_SNAKE_CASE  			=					{"""col_1""": [3, 2, 1, 0], """col_2""": ["""a""", """b""", """c""", """d"""]}
          return Dataset.from_dict(snake_case__   )






       def 							UpperCamelCase					(				self   )     ->      Tuple:
          _SCREAMING_SNAKE_CASE  			=					self._create_example_records()
          _SCREAMING_SNAKE_CASE  			=					Dataset.from_list(snake_case__   )
          self.assertListEqual(dset.column_names							,				["""col_1""", """col_2"""]   )
          for i, r in enumerate(snake_case__   ):
             self.assertDictEqual(snake_case__							,				example_records[i]   )






       def 							UpperCamelCase					(				self   )     ->      Optional[int]:
          _SCREAMING_SNAKE_CASE  			=					self._create_example_records()
          _SCREAMING_SNAKE_CASE  			=					Dataset.from_list(snake_case__   )
          _SCREAMING_SNAKE_CASE  			=					Dataset.from_dict({k: [r[k] for r in example_records] for k in example_records[0]}   )
          self.assertEqual(dset.info							,				dset_from_dict.info   )






       def 							UpperCamelCase					(				self   )     ->      Optional[Any]:  # checks what happens with missing columns
          _SCREAMING_SNAKE_CASE  			=					[{"""col_1""": 1}, {"""col_2""": """x"""}]
          _SCREAMING_SNAKE_CASE  			=					Dataset.from_list(snake_case__   )
          self.assertDictEqual(dset[0]							,				{"""col_1""": 1}   )
          self.assertDictEqual(dset[1]							,				{"""col_1""": None}   )  # NB: first record is used for columns






       def 							UpperCamelCase					(				self   )     ->      int:  # checks if the type can be inferred from the second record
          _SCREAMING_SNAKE_CASE  			=					[{"""col_1""": []}, {"""col_1""": [1, 2]}]
          _SCREAMING_SNAKE_CASE  			=					Dataset.from_list(snake_case__   )
          self.assertEqual(dset.info.features["""col_1"""]							,				Sequence(Value("""int64"""   )   )   )






       def 							UpperCamelCase					(				self   )     ->      Optional[int]:
          _SCREAMING_SNAKE_CASE  			=					Dataset.from_list([]   )
          self.assertEqual(len(snake_case__   )							,				0   )
          self.assertListEqual(dset.column_names							,				[]   )












from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


SCREAMING_SNAKE_CASE:     Any									= {
    '''configuration_pegasus_x''': ['''PEGASUS_X_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''PegasusXConfig'''],
}

try:
						if not is_torch_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						SCREAMING_SNAKE_CASE:     List[Any]									= [
						    '''PEGASUS_X_PRETRAINED_MODEL_ARCHIVE_LIST''',
						    '''PegasusXForConditionalGeneration''',
						    '''PegasusXModel''',
						    '''PegasusXPreTrainedModel''',
						]


if TYPE_CHECKING:
						from .configuration_pegasus_x import PEGASUS_X_PRETRAINED_CONFIG_ARCHIVE_MAP, PegasusXConfig

						try:
												if not is_torch_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .modeling_pegasus_x import (
												    PEGASUS_X_PRETRAINED_MODEL_ARCHIVE_LIST,
												    PegasusXForConditionalGeneration,
												    PegasusXModel,
												    PegasusXPreTrainedModel,
												)


else:
						import sys

						SCREAMING_SNAKE_CASE:     List[Any]									= _LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)