'''simple docstring'''





from unittest import TestCase

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




class 		SCREAMING_SNAKE_CASE     (					UpperCamelCase_	):







				'''simple docstring'''





				def  snake_case__				(						self					:						int					)							->Any:


										'''simple docstring'''




										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  snake_case__				(						self					:						Optional[int]					)							->Union[str, Any]:


										'''simple docstring'''




										_UpperCamelCase			:			Optional[Any]   			=						{"col_1": [3, 2, 1, 0], "col_2": ["a", "b", "c", "d"]}
										return Dataset.from_dict(__A					)





				def  snake_case__				(						self					:						int					)							->Union[str, Any]:


										'''simple docstring'''




										_UpperCamelCase			:			str   			=						self._create_example_records()
										_UpperCamelCase			:			List[Any]   			=						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  snake_case__				(						self					:						Optional[Any]					)							->Union[str, Any]:


										'''simple docstring'''




										_UpperCamelCase			:			int   			=						self._create_example_records()
										_UpperCamelCase			:			Dict   			=						Dataset.from_list(__A					)
										_UpperCamelCase			:			List[str]   			=						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  snake_case__				(						self					:						List[str]					)							->Optional[int]:  # checks what happens with missing columns


										'''simple docstring'''




										_UpperCamelCase			:			Union[str, Any]   			=						[{"col_1": 1}, {"col_2": "x"}]
										_UpperCamelCase			:			Union[str, Any]   			=						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  snake_case__				(						self					:						Union[str, Any]					)							->str:  # checks if the type can be inferred from the second record


										'''simple docstring'''




										_UpperCamelCase			:			List[Any]   			=						[{"col_1": []}, {"col_1": [1, 2]}]
										_UpperCamelCase			:			int   			=						Dataset.from_list(__A					)
										self.assertEqual(dset.info.features["col_1"]       ,		Sequence(Value("int64"					)					)					)







				def  snake_case__				(						self					:						Any					)							->Any:


										'''simple docstring'''




										_UpperCamelCase			:			Tuple   			=						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_flax_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


lowerCAmelCase_	:		Union[str, Any]			=     {"""configuration_opt""": ["""OPT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """OPTConfig"""]}

try:
			if not is_torch_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			lowerCAmelCase_	:		Tuple			=     [
			    """OPT_PRETRAINED_MODEL_ARCHIVE_LIST""",
			    """OPTForCausalLM""",
			    """OPTModel""",
			    """OPTPreTrainedModel""",
			    """OPTForSequenceClassification""",
			    """OPTForQuestionAnswering""",
			]

try:
			if not is_tf_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			lowerCAmelCase_	:		str			=     ["""TFOPTForCausalLM""", """TFOPTModel""", """TFOPTPreTrainedModel"""]

try:
			if not is_flax_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			lowerCAmelCase_	:		List[Any]			=     [
			    """FlaxOPTForCausalLM""",
			    """FlaxOPTModel""",
			    """FlaxOPTPreTrainedModel""",
			]


if TYPE_CHECKING:
			from .configuration_opt import OPT_PRETRAINED_CONFIG_ARCHIVE_MAP, OPTConfig

			try:
						if not is_torch_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .modeling_opt import (
						    OPT_PRETRAINED_MODEL_ARCHIVE_LIST,
						    OPTForCausalLM,
						    OPTForQuestionAnswering,
						    OPTForSequenceClassification,
						    OPTModel,
						    OPTPreTrainedModel,
						)

			try:
						if not is_tf_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .modeling_tf_opt import TFOPTForCausalLM, TFOPTModel, TFOPTPreTrainedModel

			try:
						if not is_flax_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .modeling_flax_opt import FlaxOPTForCausalLM, FlaxOPTModel, FlaxOPTPreTrainedModel

else:
			import sys

			lowerCAmelCase_	:		Any			=     _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)


