


'''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 							_a				(				self			:							List[Any]			):

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

        '''simple docstring'''




        A_    :	str							 =					{"""col_1""": [3, 2, 1, 0], """col_2""": ["""a""", """b""", """c""", """d"""]}
        return Dataset.from_dict(__lowercase			)






  def 							_a				(				self			:							str			):

        '''simple docstring'''




        A_    :	str							 =					self._create_example_records()
        A_    :	int							 =					Dataset.from_list(__lowercase			)
        self.assertListEqual(dset.column_names						,["""col_1""", """col_2"""]			)
        for i, r in enumerate(__lowercase			):
              self.assertDictEqual(__lowercase						,example_records[i]			)






  def 							_a				(				self			:							List[Any]			):

        '''simple docstring'''




        A_    :	Union[str, Any]							 =					self._create_example_records()
        A_    :	List[Any]							 =					Dataset.from_list(__lowercase			)
        A_    :	Union[str, Any]							 =					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			:							Optional[int]			):  # checks what happens with missing columns

        '''simple docstring'''




        A_    :	List[Any]							 =					[{"""col_1""": 1}, {"""col_2""": """x"""}]
        A_    :	Optional[int]							 =					Dataset.from_list(__lowercase			)
        self.assertDictEqual(dset[0]						,{"""col_1""": 1}			)
        self.assertDictEqual(dset[1]						,{"""col_1""": None}			)  # NB: first record is used for columns






  def 							_a				(				self			:							int			):  # checks if the type can be inferred from the second record

        '''simple docstring'''




        A_    :	Tuple							 =					[{"""col_1""": []}, {"""col_1""": [1, 2]}]
        A_    :	str							 =					Dataset.from_list(__lowercase			)
        self.assertEqual(dset.info.features["""col_1"""]						,Sequence(Value("""int64"""			)			)			)






  def 							_a				(				self			:							List[str]			):

        '''simple docstring'''




        A_    :	Dict							 =					Dataset.from_list([]			)
        self.assertEqual(len(__lowercase			)						,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,
    is_vision_available,
)


UpperCAmelCase					 =	{
    '''configuration_owlvit''': [
        '''OWLVIT_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''OwlViTConfig''',
        '''OwlViTOnnxConfig''',
        '''OwlViTTextConfig''',
        '''OwlViTVisionConfig''',
    ],
    '''processing_owlvit''': ['''OwlViTProcessor'''],
}


try:
       if not is_vision_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       UpperCAmelCase					 =	['''OwlViTFeatureExtractor''']
       UpperCAmelCase					 =	['''OwlViTImageProcessor''']

try:
       if not is_torch_available():
              raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
       pass
else:
       UpperCAmelCase					 =	[
           '''OWLVIT_PRETRAINED_MODEL_ARCHIVE_LIST''',
           '''OwlViTModel''',
           '''OwlViTPreTrainedModel''',
           '''OwlViTTextModel''',
           '''OwlViTVisionModel''',
           '''OwlViTForObjectDetection''',
       ]

if TYPE_CHECKING:
       from .configuration_owlvit import (
           OWLVIT_PRETRAINED_CONFIG_ARCHIVE_MAP,
           OwlViTConfig,
           OwlViTOnnxConfig,
           OwlViTTextConfig,
           OwlViTVisionConfig,
       )
       from .processing_owlvit import OwlViTProcessor

       try:
              if not is_vision_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .feature_extraction_owlvit import OwlViTFeatureExtractor
              from .image_processing_owlvit import OwlViTImageProcessor

       try:
              if not is_torch_available():
                     raise OptionalDependencyNotAvailable()
       except OptionalDependencyNotAvailable:
              pass
       else:
              from .modeling_owlvit import (
                  OWLVIT_PRETRAINED_MODEL_ARCHIVE_LIST,
                  OwlViTForObjectDetection,
                  OwlViTModel,
                  OwlViTPreTrainedModel,
                  OwlViTTextModel,
                  OwlViTVisionModel,
              )

else:
       import sys

       UpperCAmelCase					 =	_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)


