


"""simple docstring"""




from unittest import TestCase

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


		'''simple docstring'''



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

		def 			__UpperCAmelCase       (  self      ):
				__a           =			self._create_example_records()
				__a           =			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      ):
				__a           =			self._create_example_records()
				__a           =			Dataset.from_list(_a      )
				__a           =			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      ):  # checks what happens with missing columns
				__a           =			[{'''col_1''': 1}, {'''col_2''': '''x'''}]
				__a           =			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      ):  # checks if the type can be inferred from the second record
				__a           =			[{'''col_1''': []}, {'''col_1''': [1, 2]}]
				__a           =			Dataset.from_list(_a      )
				self.assertEqual(dset.info.features['''col_1''']							, Sequence(Value('''int64'''      )      )      )





		def 			__UpperCAmelCase       (  self      ):
				__a           =			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_sentencepiece_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


lowerCamelCase :      int					 =     {"configuration_mbart": ["MBART_PRETRAINED_CONFIG_ARCHIVE_MAP", "MBartConfig", "MBartOnnxConfig"]}

try:
     if not is_sentencepiece_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     lowerCamelCase :      List[Any]					 =     ["MBartTokenizer"]

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

try:
     if not is_torch_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     lowerCamelCase :      int					 =     [
         "MBART_PRETRAINED_MODEL_ARCHIVE_LIST",
         "MBartForCausalLM",
         "MBartForConditionalGeneration",
         "MBartForQuestionAnswering",
         "MBartForSequenceClassification",
         "MBartModel",
         "MBartPreTrainedModel",
     ]

try:
     if not is_tf_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     lowerCamelCase :      Union[str, Any]					 =     [
         "TFMBartForConditionalGeneration",
         "TFMBartModel",
         "TFMBartPreTrainedModel",
     ]

try:
     if not is_flax_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     lowerCamelCase :      Optional[Any]					 =     [
         "FlaxMBartForConditionalGeneration",
         "FlaxMBartForQuestionAnswering",
         "FlaxMBartForSequenceClassification",
         "FlaxMBartModel",
         "FlaxMBartPreTrainedModel",
     ]


if TYPE_CHECKING:
     from .configuration_mbart import MBART_PRETRAINED_CONFIG_ARCHIVE_MAP, MBartConfig, MBartOnnxConfig

     try:
          if not is_sentencepiece_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .tokenization_mbart import MBartTokenizer

     try:
          if not is_tokenizers_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .tokenization_mbart_fast import MBartTokenizerFast

     try:
          if not is_torch_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_mbart import (
              MBART_PRETRAINED_MODEL_ARCHIVE_LIST,
              MBartForCausalLM,
              MBartForConditionalGeneration,
              MBartForQuestionAnswering,
              MBartForSequenceClassification,
              MBartModel,
              MBartPreTrainedModel,
          )

     try:
          if not is_tf_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_tf_mbart import TFMBartForConditionalGeneration, TFMBartModel, TFMBartPreTrainedModel

     try:
          if not is_flax_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_flax_mbart import (
              FlaxMBartForConditionalGeneration,
              FlaxMBartForQuestionAnswering,
              FlaxMBartForSequenceClassification,
              FlaxMBartModel,
              FlaxMBartPreTrainedModel,
          )

else:
     import sys

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