






from unittest import TestCase

from datasets import Sequence, Value
from datasets.arrow_dataset import Dataset
class 		SCREAMING_SNAKE_CASE__	(  UpperCAmelCase     ):

  '''simple docstring'''







  def  lowerCamelCase       (      self		:			List[str]							)						->	Dict:


         """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  lowerCamelCase       (      self		:			List[str]							)						->	List[Any]:


         """simple docstring"""
         _UpperCAmelCase							=    {"""col_1""": [3, 2, 1, 0], """col_2""": ["""a""", """b""", """c""", """d"""]}
         return Dataset.from_dict(lowerCamelCase							)


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


         """simple docstring"""
         _UpperCAmelCase							=    self._create_example_records()
         _UpperCAmelCase							=    Dataset.from_list(lowerCamelCase							)
         self.assertListEqual(dset.column_names       ,				["""col_1""", """col_2"""]							)
         for i, r in enumerate(lowerCamelCase							):
                self.assertDictEqual(lowerCamelCase       ,				example_records[i]							)


  def  lowerCamelCase       (      self		:			List[Any]							)						->	Union[str, Any]:


         """simple docstring"""
         _UpperCAmelCase							=    self._create_example_records()
         _UpperCAmelCase							=    Dataset.from_list(lowerCamelCase							)
         _UpperCAmelCase							=    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  lowerCamelCase       (      self		:			str							)						->	Any:  # checks what happens with missing columns


         """simple docstring"""
         _UpperCAmelCase							=    [{"""col_1""": 1}, {"""col_2""": """x"""}]
         _UpperCAmelCase							=    Dataset.from_list(lowerCamelCase							)
         self.assertDictEqual(dset[0]       ,				{"""col_1""": 1}							)
         self.assertDictEqual(dset[1]       ,				{"""col_1""": None}							)  # NB: first record is used for columns


  def  lowerCamelCase       (      self		:			List[str]							)						->	Optional[int]:  # checks if the type can be inferred from the second record


         """simple docstring"""
         _UpperCAmelCase							=    [{"""col_1""": []}, {"""col_1""": [1, 2]}]
         _UpperCAmelCase							=    Dataset.from_list(lowerCamelCase							)
         self.assertEqual(dset.info.features["""col_1"""]       ,				Sequence(Value("""int64"""							)							)							)





  def  lowerCamelCase       (      self		:			Optional[int]							)						->	Optional[int]:


         """simple docstring"""
         _UpperCAmelCase							=    Dataset.from_list([]							)
         self.assertEqual(len(lowerCamelCase							)       ,				0							)
         self.assertListEqual(dset.column_names       ,				[]							)



'''simple docstring'''



from .dependency_versions_table import deps
from .utils.versions import require_version, require_version_core


# define which module versions we always want to check at run time
# (usually the ones defined in `install_requires` in setup.py)
#
# order specific notes:
# - tqdm must be checked before tokenizers

A__						:   Dict				=    [
    """python""",
    """tqdm""",
    """regex""",
    """requests""",
    """packaging""",
    """filelock""",
    """numpy""",
    """tokenizers""",
    """huggingface-hub""",
    """safetensors""",
    """accelerate""",
    """pyyaml""",
]

for pkg in pkgs_to_check_at_runtime:
      if pkg in deps:
            if pkg == "tokenizers":
                  # must be loaded here, or else tqdm check may fail
                  from .utils import is_tokenizers_available

                  if not is_tokenizers_available():
                        continue  # not required, check version only if installed
            elif pkg == "accelerate":
                  # must be loaded here, or else tqdm check may fail
                  from .utils import is_accelerate_available

                  # Maybe switch to is_torch_available in the future here so that Accelerate is hard dep of
                  # Transformers with PyTorch
                  if not is_accelerate_available():
                        continue  # not required, check version only if installed

            require_version_core(deps[pkg])
      else:
            raise ValueError(f'''can\'t find {pkg} in {deps.keys()}, check dependency_versions_table.py''')



def      UpperCAmelCase__   (      UpperCAmelCase_       :							List[Any] ,       UpperCAmelCase_       :							List[Any]=None				)	->						List[Any]:
     require_version(deps[pkg] ,       UpperCAmelCase_				)






