'''simple docstring'''

from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available


_A			:      List[str]					      =				{
    '''configuration_data2vec_audio''': ['''DATA2VEC_AUDIO_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''Data2VecAudioConfig'''],
    '''configuration_data2vec_text''': [
        '''DATA2VEC_TEXT_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''Data2VecTextConfig''',
        '''Data2VecTextOnnxConfig''',
    ],
    '''configuration_data2vec_vision''': [
        '''DATA2VEC_VISION_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''Data2VecVisionConfig''',
        '''Data2VecVisionOnnxConfig''',
    ],
}

try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 _A			:      List[Any]					      =				[
     '''DATA2VEC_AUDIO_PRETRAINED_MODEL_ARCHIVE_LIST''',
     '''Data2VecAudioForAudioFrameClassification''',
     '''Data2VecAudioForCTC''',
     '''Data2VecAudioForSequenceClassification''',
     '''Data2VecAudioForXVector''',
     '''Data2VecAudioModel''',
     '''Data2VecAudioPreTrainedModel''',
 ]
 _A			:      Tuple					      =				[
     '''DATA2VEC_TEXT_PRETRAINED_MODEL_ARCHIVE_LIST''',
     '''Data2VecTextForCausalLM''',
     '''Data2VecTextForMaskedLM''',
     '''Data2VecTextForMultipleChoice''',
     '''Data2VecTextForQuestionAnswering''',
     '''Data2VecTextForSequenceClassification''',
     '''Data2VecTextForTokenClassification''',
     '''Data2VecTextModel''',
     '''Data2VecTextPreTrainedModel''',
 ]
 _A			:      Union[str, Any]					      =				[
     '''DATA2VEC_VISION_PRETRAINED_MODEL_ARCHIVE_LIST''',
     '''Data2VecVisionForImageClassification''',
     '''Data2VecVisionForMaskedImageModeling''',
     '''Data2VecVisionForSemanticSegmentation''',
     '''Data2VecVisionModel''',
     '''Data2VecVisionPreTrainedModel''',
 ]

if is_tf_available():
 _A			:      Union[str, Any]					      =				[
     '''TFData2VecVisionForImageClassification''',
     '''TFData2VecVisionForSemanticSegmentation''',
     '''TFData2VecVisionModel''',
     '''TFData2VecVisionPreTrainedModel''',
 ]

if TYPE_CHECKING:
 from .configuration_dataavec_audio import DATA2VEC_AUDIO_PRETRAINED_CONFIG_ARCHIVE_MAP, DataaVecAudioConfig
 from .configuration_dataavec_text import (
     DATA2VEC_TEXT_PRETRAINED_CONFIG_ARCHIVE_MAP,
     DataaVecTextConfig,
     DataaVecTextOnnxConfig,
 )
 from .configuration_dataavec_vision import (
     DATA2VEC_VISION_PRETRAINED_CONFIG_ARCHIVE_MAP,
     DataaVecVisionConfig,
     DataaVecVisionOnnxConfig,
 )

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_dataavec_audio import (
      DATA2VEC_AUDIO_PRETRAINED_MODEL_ARCHIVE_LIST,
      DataaVecAudioForAudioFrameClassification,
      DataaVecAudioForCTC,
      DataaVecAudioForSequenceClassification,
      DataaVecAudioForXVector,
      DataaVecAudioModel,
      DataaVecAudioPreTrainedModel,
  )
  from .modeling_dataavec_text import (
      DATA2VEC_TEXT_PRETRAINED_MODEL_ARCHIVE_LIST,
      DataaVecTextForCausalLM,
      DataaVecTextForMaskedLM,
      DataaVecTextForMultipleChoice,
      DataaVecTextForQuestionAnswering,
      DataaVecTextForSequenceClassification,
      DataaVecTextForTokenClassification,
      DataaVecTextModel,
      DataaVecTextPreTrainedModel,
  )
  from .modeling_dataavec_vision import (
      DATA2VEC_VISION_PRETRAINED_MODEL_ARCHIVE_LIST,
      DataaVecVisionForImageClassification,
      DataaVecVisionForMaskedImageModeling,
      DataaVecVisionForSemanticSegmentation,
      DataaVecVisionModel,
      DataaVecVisionPreTrainedModel,
  )
 if is_tf_available():
  from .modeling_tf_dataavec_vision import (
      TFDataaVecVisionForImageClassification,
      TFDataaVecVisionForSemanticSegmentation,
      TFDataaVecVisionModel,
      TFDataaVecVisionPreTrainedModel,
  )

else:
 import sys

 _A			:      Tuple					      =				_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)







'''simple docstring'''

from unittest import TestCase

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







class 				_lowercase     (				UpperCAmelCase__			):


 '''simple docstring'''






 def a					(      self   :	int							)  ->    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 a					(      self   :	List[Any]							)  ->    Any:
  __lowerCAmelCase											=						{"""col_1""": [3, 2, 1, 0], """col_2""": ["""a""", """b""", """c""", """d"""]}
  return Dataset.from_dict(SCREAMING_SNAKE_CASE__							)
 def a					(      self   :	List[Any]							)  ->    Tuple:
  __lowerCAmelCase											=						self._create_example_records()
  __lowerCAmelCase											=						Dataset.from_list(SCREAMING_SNAKE_CASE__							)
  self.assertListEqual(dset.column_names      ,       ["""col_1""", """col_2"""]							)
  for i, r in enumerate(SCREAMING_SNAKE_CASE__							):
   self.assertDictEqual(SCREAMING_SNAKE_CASE__      ,       example_records[i]							)
 def a					(      self   :	Tuple							)  ->    List[str]:
  __lowerCAmelCase											=						self._create_example_records()
  __lowerCAmelCase											=						Dataset.from_list(SCREAMING_SNAKE_CASE__							)
  __lowerCAmelCase											=						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 a					(      self   :	List[str]							)  ->    List[str]:  # checks what happens with missing columns
  __lowerCAmelCase											=						[{"""col_1""": 1}, {"""col_2""": """x"""}]
  __lowerCAmelCase											=						Dataset.from_list(SCREAMING_SNAKE_CASE__							)
  self.assertDictEqual(dset[0]      ,       {"""col_1""": 1}							)
  self.assertDictEqual(dset[1]      ,       {"""col_1""": None}							)  # NB: first record is used for columns
 def a					(      self   :	Dict							)  ->    Optional[int]:  # checks if the type can be inferred from the second record
  __lowerCAmelCase											=						[{"""col_1""": []}, {"""col_1""": [1, 2]}]
  __lowerCAmelCase											=						Dataset.from_list(SCREAMING_SNAKE_CASE__							)
  self.assertEqual(dset.info.features["""col_1"""]      ,       Sequence(Value("""int64"""							)							)							)





 def a					(      self   :	Optional[Any]							)  ->    Tuple:
  __lowerCAmelCase											=						Dataset.from_list([]							)
  self.assertEqual(len(SCREAMING_SNAKE_CASE__							)      ,       0							)
  self.assertListEqual(dset.column_names      ,       []							)






