





from unittest import TestCase

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





class 					A_					(   UpperCAmelCase						):







       """simple docstring"""





       def  __UpperCAmelCase			(     self						:						Tuple	)    ->       Optional[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						:						List[str]	)    ->       Tuple:
         _lowercase						    =			{'col_1': [3, 2, 1, 0], 'col_2': ['a', 'b', 'c', 'd']}
         return Dataset.from_dict(__A	)







       def  __UpperCAmelCase			(     self						:						Optional[Any]	)    ->       Any:
         _lowercase						    =			self._create_example_records()
         _lowercase						    =			Dataset.from_list(__A	)
         self.assertListEqual(dset.column_names    ,['col_1', 'col_2']	)
         for i, r in enumerate(__A	):
           self.assertDictEqual(__A    ,example_records[i]	)







       def  __UpperCAmelCase			(     self						:						Union[str, Any]	)    ->       List[str]:
         _lowercase						    =			self._create_example_records()
         _lowercase						    =			Dataset.from_list(__A	)
         _lowercase						    =			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						:						int	)    ->       Tuple:  # checks what happens with missing columns
         _lowercase						    =			[{'col_1': 1}, {'col_2': 'x'}]
         _lowercase						    =			Dataset.from_list(__A	)
         self.assertDictEqual(dset[0]    ,{'col_1': 1}	)
         self.assertDictEqual(dset[1]    ,{'col_1': None}	)  # NB: first record is used for columns







       def  __UpperCAmelCase			(     self						:						List[Any]	)    ->       List[Any]:  # checks if the type can be inferred from the second record
         _lowercase						    =			[{'col_1': []}, {'col_1': [1, 2]}]
         _lowercase						    =			Dataset.from_list(__A	)
         self.assertEqual(dset.info.features['col_1']    ,Sequence(Value('int64'	)	)	)







       def  __UpperCAmelCase			(     self						:						List[str]	)    ->       str:
         _lowercase						    =			Dataset.from_list([]	)
         self.assertEqual(len(__A	)    ,0	)
         self.assertListEqual(dset.column_names    ,[]	)




"""simple docstring"""




from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


_lowerCAmelCase							:   List[Any]				=				{
    "configuration_lilt": ["LILT_PRETRAINED_CONFIG_ARCHIVE_MAP", "LiltConfig"],
}

try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 _lowerCAmelCase							:   int				=				[
     "LILT_PRETRAINED_MODEL_ARCHIVE_LIST",
     "LiltForQuestionAnswering",
     "LiltForSequenceClassification",
     "LiltForTokenClassification",
     "LiltModel",
     "LiltPreTrainedModel",
 ]

if TYPE_CHECKING:
 from .configuration_lilt import LILT_PRETRAINED_CONFIG_ARCHIVE_MAP, LiltConfig

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_lilt import (
      LILT_PRETRAINED_MODEL_ARCHIVE_LIST,
      LiltForQuestionAnswering,
      LiltForSequenceClassification,
      LiltForTokenClassification,
      LiltModel,
      LiltPreTrainedModel,
  )

else:
 import sys

 _lowerCAmelCase							:   Optional[int]				=				_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)
