


'''simple docstring'''

from unittest import TestCase

from datasets import Sequence, Value
from datasets.arrow_dataset import Dataset
class     __lowerCAmelCase		(lowercase_	):





      '''simple docstring'''






      def  UpperCamelCase__						(self       :       int					):

             '''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  UpperCamelCase__						(self       :       Optional[int]					):

             '''simple docstring'''







             lowercase__      =					{'''col_1''': [3, 2, 1, 0], '''col_2''': ['''a''', '''b''', '''c''', '''d''']}
             return Dataset.from_dict(UpperCamelCase					)



      def  UpperCamelCase__						(self       :       int					):

             '''simple docstring'''







             lowercase__      =					self._create_example_records()
             lowercase__      =					Dataset.from_list(UpperCamelCase					)
             self.assertListEqual(dset.column_names  ,		['''col_1''', '''col_2''']					)
             for i, r in enumerate(UpperCamelCase					):
                    self.assertDictEqual(UpperCamelCase  ,		example_records[i]					)



      def  UpperCamelCase__						(self       :       Any					):

             '''simple docstring'''







             lowercase__      =					self._create_example_records()
             lowercase__      =					Dataset.from_list(UpperCamelCase					)
             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       :       Any					):  # checks what happens with missing columns

             '''simple docstring'''







             lowercase__      =					[{'''col_1''': 1}, {'''col_2''': '''x'''}]
             lowercase__      =					Dataset.from_list(UpperCamelCase					)
             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

             '''simple docstring'''







             lowercase__      =					[{'''col_1''': []}, {'''col_1''': [1, 2]}]
             lowercase__      =					Dataset.from_list(UpperCamelCase					)
             self.assertEqual(dset.info.features['''col_1''']  ,		Sequence(Value('''int64'''					)					)					)






      def  UpperCamelCase__						(self       :       Optional[Any]					):

             '''simple docstring'''







             lowercase__      =					Dataset.from_list([]					)
             self.assertEqual(len(UpperCamelCase					)  ,		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				:  Tuple    		=      {
    'configuration_distilbert': [
        'DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_MAP',
        'DistilBertConfig',
        'DistilBertOnnxConfig',
    ],
    'tokenization_distilbert': ['DistilBertTokenizer'],
}

try:
 if not is_tokenizers_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 lowerCamelCase				:  str    		=      ['DistilBertTokenizerFast']

try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 lowerCamelCase				:  List[str]    		=      [
     'DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST',
     'DistilBertForMaskedLM',
     'DistilBertForMultipleChoice',
     'DistilBertForQuestionAnswering',
     'DistilBertForSequenceClassification',
     'DistilBertForTokenClassification',
     'DistilBertModel',
     'DistilBertPreTrainedModel',
 ]

try:
 if not is_tf_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 lowerCamelCase				:  Union[str, Any]    		=      [
     'TF_DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST',
     'TFDistilBertForMaskedLM',
     'TFDistilBertForMultipleChoice',
     'TFDistilBertForQuestionAnswering',
     'TFDistilBertForSequenceClassification',
     'TFDistilBertForTokenClassification',
     'TFDistilBertMainLayer',
     'TFDistilBertModel',
     'TFDistilBertPreTrainedModel',
 ]

try:
 if not is_flax_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 lowerCamelCase				:  str    		=      [
     'FlaxDistilBertForMaskedLM',
     'FlaxDistilBertForMultipleChoice',
     'FlaxDistilBertForQuestionAnswering',
     'FlaxDistilBertForSequenceClassification',
     'FlaxDistilBertForTokenClassification',
     'FlaxDistilBertModel',
     'FlaxDistilBertPreTrainedModel',
 ]


if TYPE_CHECKING:
 from .configuration_distilbert import (
     DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_MAP,
     DistilBertConfig,
     DistilBertOnnxConfig,
 )
 from .tokenization_distilbert import DistilBertTokenizer

 try:
  if not is_tokenizers_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .tokenization_distilbert_fast import DistilBertTokenizerFast

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_distilbert import (
      DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
      DistilBertForMaskedLM,
      DistilBertForMultipleChoice,
      DistilBertForQuestionAnswering,
      DistilBertForSequenceClassification,
      DistilBertForTokenClassification,
      DistilBertModel,
      DistilBertPreTrainedModel,
  )

 try:
  if not is_tf_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_tf_distilbert import (
      TF_DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
      TFDistilBertForMaskedLM,
      TFDistilBertForMultipleChoice,
      TFDistilBertForQuestionAnswering,
      TFDistilBertForSequenceClassification,
      TFDistilBertForTokenClassification,
      TFDistilBertMainLayer,
      TFDistilBertModel,
      TFDistilBertPreTrainedModel,
  )

 try:
  if not is_flax_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_flax_distilbert import (
      FlaxDistilBertForMaskedLM,
      FlaxDistilBertForMultipleChoice,
      FlaxDistilBertForQuestionAnswering,
      FlaxDistilBertForSequenceClassification,
      FlaxDistilBertForTokenClassification,
      FlaxDistilBertModel,
      FlaxDistilBertPreTrainedModel,
  )

else:
 import sys

 lowerCamelCase				:  int    		=      _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)




