






from unittest import TestCase

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



class 							SCREAMING_SNAKE_CASE__		(       UpperCamelCase_		):





     """simple docstring"""






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



     def  _lowercase  (      self  :						int ):
      snake_case__				:   str     =						self._create_example_records()
      snake_case__				:   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  _lowercase  (      self  :						Optional[Any] ):
      snake_case__				:   int     =						self._create_example_records()
      snake_case__				:   Dict     =						Dataset.from_list(__A )
      snake_case__				:   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  _lowercase  (      self  :						List[str] ):  # checks what happens with missing columns
      snake_case__				:   Union[str, Any]     =						[{"col_1": 1}, {"col_2": "x"}]
      snake_case__				:   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  _lowercase  (      self  :						Union[str, Any] ):  # checks if the type can be inferred from the second record
      snake_case__				:   List[Any]     =						[{"col_1": []}, {"col_1": [1, 2]}]
      snake_case__				:   int     =						Dataset.from_list(__A )
      self.assertEqual(dset.info.features["col_1"]							,	Sequence(Value("int64" ) ) )






     def  _lowercase  (      self  :						Any ):
      snake_case__				:   Tuple     =						Dataset.from_list([] )
      self.assertEqual(len(__A )							,	0 )
      self.assertListEqual(dset.column_names							,	[] )











from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_sentencepiece_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


__lowerCamelCase      :    List[str]   		=   {"""configuration_xlnet""": ["""XLNET_PRETRAINED_CONFIG_ARCHIVE_MAP""", """XLNetConfig"""]}

try:
	if not is_sentencepiece_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	__lowerCamelCase      :    str   		=   ["""XLNetTokenizer"""]

try:
	if not is_tokenizers_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	__lowerCamelCase      :    Dict   		=   ["""XLNetTokenizerFast"""]

try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	__lowerCamelCase      :    str   		=   [
	    """XLNET_PRETRAINED_MODEL_ARCHIVE_LIST""",
	    """XLNetForMultipleChoice""",
	    """XLNetForQuestionAnswering""",
	    """XLNetForQuestionAnsweringSimple""",
	    """XLNetForSequenceClassification""",
	    """XLNetForTokenClassification""",
	    """XLNetLMHeadModel""",
	    """XLNetModel""",
	    """XLNetPreTrainedModel""",
	    """load_tf_weights_in_xlnet""",
	]

try:
	if not is_tf_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	__lowerCamelCase      :    Dict   		=   [
	    """TF_XLNET_PRETRAINED_MODEL_ARCHIVE_LIST""",
	    """TFXLNetForMultipleChoice""",
	    """TFXLNetForQuestionAnsweringSimple""",
	    """TFXLNetForSequenceClassification""",
	    """TFXLNetForTokenClassification""",
	    """TFXLNetLMHeadModel""",
	    """TFXLNetMainLayer""",
	    """TFXLNetModel""",
	    """TFXLNetPreTrainedModel""",
	]


if TYPE_CHECKING:
	from .configuration_xlnet import XLNET_PRETRAINED_CONFIG_ARCHIVE_MAP, XLNetConfig

	try:
		if not is_sentencepiece_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .tokenization_xlnet import XLNetTokenizer

	try:
		if not is_tokenizers_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .tokenization_xlnet_fast import XLNetTokenizerFast

	try:
		if not is_torch_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_xlnet import (
		    XLNET_PRETRAINED_MODEL_ARCHIVE_LIST,
		    XLNetForMultipleChoice,
		    XLNetForQuestionAnswering,
		    XLNetForQuestionAnsweringSimple,
		    XLNetForSequenceClassification,
		    XLNetForTokenClassification,
		    XLNetLMHeadModel,
		    XLNetModel,
		    XLNetPreTrainedModel,
		    load_tf_weights_in_xlnet,
		)

	try:
		if not is_tf_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_tf_xlnet import (
		    TF_XLNET_PRETRAINED_MODEL_ARCHIVE_LIST,
		    TFXLNetForMultipleChoice,
		    TFXLNetForQuestionAnsweringSimple,
		    TFXLNetForSequenceClassification,
		    TFXLNetForTokenClassification,
		    TFXLNetLMHeadModel,
		    TFXLNetMainLayer,
		    TFXLNetModel,
		    TFXLNetPreTrainedModel,
		)

else:
	import sys

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



