






import unittest

import numpy as np

from transformers.testing_utils import require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
	import torch

if is_vision_available():
	from PIL import Image

	from transformers import MobileViTImageProcessor



class 							SCREAMING_SNAKE_CASE__		(       unittest.TestCase		):





					"""simple docstring"""






					def __init__(      self  :						Dict							,	__A  :						Optional[Any]							,	__A  :						Union[str, Any]=7							,	__A  :						Any=3							,	__A  :						List[str]=1_8							,	__A  :						Any=3_0							,	__A  :						Tuple=4_0_0							,	__A  :						Any=True							,	__A  :						Tuple=None							,	__A  :						Optional[Any]=True							,	__A  :						str=None							,	__A  :						str=True							,	):
						snake_case__				:   Optional[int]     =						size if size is not None else {"shortest_edge": 2_0}
						snake_case__				:   int     =						crop_size if crop_size is not None else {"height": 1_8, "width": 1_8}
						snake_case__				:   Union[str, Any]     =						parent
						snake_case__				:   Any     =						batch_size
						snake_case__				:   Dict     =						num_channels
						snake_case__				:   List[str]     =						image_size
						snake_case__				:   Optional[int]     =						min_resolution
						snake_case__				:   List[str]     =						max_resolution
						snake_case__				:   str     =						do_resize
						snake_case__				:   int     =						size
						snake_case__				:   Optional[int]     =						do_center_crop
						snake_case__				:   List[Any]     =						crop_size
						snake_case__				:   Optional[Any]     =						do_flip_channel_order






					def  _lowercase  (      self  :						Union[str, Any] ):
						return {
						    "do_resize": self.do_resize,
						    "size": self.size,
						    "do_center_crop": self.do_center_crop,
						    "crop_size": self.crop_size,
						    "do_flip_channel_order": self.do_flip_channel_order,
						}



@require_torch
@require_vision
class 							SCREAMING_SNAKE_CASE__		(       UpperCamelCase_				,     unittest.TestCase		):





					"""simple docstring"""






					a_			=	MobileViTImageProcessor if is_vision_available() else None



					def  _lowercase  (      self  :						List[str] ):
						snake_case__				:   Dict     =						MobileViTImageProcessingTester(self )



					@property
					def  _lowercase  (      self  :						List[str] ):
						return self.image_processor_tester.prepare_image_processor_dict()



					def  _lowercase  (      self  :						str ):
						snake_case__				:   Optional[int]     =						self.image_processing_class(**self.image_processor_dict )
						self.assertTrue(hasattr(__A							,	"do_resize" ) )
						self.assertTrue(hasattr(__A							,	"size" ) )
						self.assertTrue(hasattr(__A							,	"do_center_crop" ) )
						self.assertTrue(hasattr(__A							,	"center_crop" ) )
						self.assertTrue(hasattr(__A							,	"do_flip_channel_order" ) )



					def  _lowercase  (      self  :						Optional[Any] ):
						snake_case__				:   Any     =						self.image_processing_class.from_dict(self.image_processor_dict )
						self.assertEqual(image_processor.size							,	{"shortest_edge": 2_0} )
						self.assertEqual(image_processor.crop_size							,	{"height": 1_8, "width": 1_8} )

						snake_case__				:   Dict     =						self.image_processing_class.from_dict(self.image_processor_dict							,	size=4_2							,	crop_size=8_4 )
						self.assertEqual(image_processor.size							,	{"shortest_edge": 4_2} )
						self.assertEqual(image_processor.crop_size							,	{"height": 8_4, "width": 8_4} )



					def  _lowercase  (      self  :						Union[str, Any] ):
						pass



					def  _lowercase  (      self  :						Optional[int] ):
						# Initialize image_processing
						snake_case__				:   Any     =						self.image_processing_class(**self.image_processor_dict )
						# create random PIL images
						snake_case__				:   Tuple     =						prepare_image_inputs(self.image_processor_tester							,	equal_resolution=__A )
						for image in image_inputs:
							self.assertIsInstance(__A							,	Image.Image )

						# Test not batched input
						snake_case__				:   List[Any]     =						image_processing(image_inputs[0]							,	return_tensors="pt" ).pixel_values
						self.assertEqual(
						    encoded_images.shape							,	(
						        1,
						        self.image_processor_tester.num_channels,
						        self.image_processor_tester.crop_size["height"],
						        self.image_processor_tester.crop_size["width"],
						    )							,	)

						# Test batched
						snake_case__				:   Optional[int]     =						image_processing(__A							,	return_tensors="pt" ).pixel_values
						self.assertEqual(
						    encoded_images.shape							,	(
						        self.image_processor_tester.batch_size,
						        self.image_processor_tester.num_channels,
						        self.image_processor_tester.crop_size["height"],
						        self.image_processor_tester.crop_size["width"],
						    )							,	)



					def  _lowercase  (      self  :						str ):
						# Initialize image_processing
						snake_case__				:   List[str]     =						self.image_processing_class(**self.image_processor_dict )
						# create random numpy tensors
						snake_case__				:   Tuple     =						prepare_image_inputs(self.image_processor_tester							,	equal_resolution=__A							,	numpify=__A )
						for image in image_inputs:
							self.assertIsInstance(__A							,	np.ndarray )

						# Test not batched input
						snake_case__				:   Tuple     =						image_processing(image_inputs[0]							,	return_tensors="pt" ).pixel_values
						self.assertEqual(
						    encoded_images.shape							,	(
						        1,
						        self.image_processor_tester.num_channels,
						        self.image_processor_tester.crop_size["height"],
						        self.image_processor_tester.crop_size["width"],
						    )							,	)

						# Test batched
						snake_case__				:   Union[str, Any]     =						image_processing(__A							,	return_tensors="pt" ).pixel_values
						self.assertEqual(
						    encoded_images.shape							,	(
						        self.image_processor_tester.batch_size,
						        self.image_processor_tester.num_channels,
						        self.image_processor_tester.crop_size["height"],
						        self.image_processor_tester.crop_size["width"],
						    )							,	)






					def  _lowercase  (      self  :						int ):
						# Initialize image_processing
						snake_case__				:   Optional[Any]     =						self.image_processing_class(**self.image_processor_dict )
						# create random PyTorch tensors
						snake_case__				:   Any     =						prepare_image_inputs(self.image_processor_tester							,	equal_resolution=__A							,	torchify=__A )
						for image in image_inputs:
							self.assertIsInstance(__A							,	torch.Tensor )

						# Test not batched input
						snake_case__				:   int     =						image_processing(image_inputs[0]							,	return_tensors="pt" ).pixel_values
						self.assertEqual(
						    encoded_images.shape							,	(
						        1,
						        self.image_processor_tester.num_channels,
						        self.image_processor_tester.crop_size["height"],
						        self.image_processor_tester.crop_size["width"],
						    )							,	)

						# Test batched
						snake_case__				:   Dict     =						image_processing(__A							,	return_tensors="pt" ).pixel_values
						self.assertEqual(
						    encoded_images.shape							,	(
						        self.image_processor_tester.batch_size,
						        self.image_processor_tester.num_channels,
						        self.image_processor_tester.crop_size["height"],
						        self.image_processor_tester.crop_size["width"],
						    )							,	)











# Lint as: python3
# pylint: enable=line-too-long
# pylint: disable=g-import-not-at-top,g-bad-import-order,wrong-import-position

__lowerCamelCase      :    Union[str, Any]   		=   """2.13.1"""

import platform

import pyarrow
from packaging import version


if version.parse(platform.python_version()) < version.parse("""3.7"""):
	raise ImportWarning(
	    """To use `datasets`, Python>=3.7 is required, and the current version of Python doesn't match this condition."""
	)

if version.parse(pyarrow.__version__).major < 8:
	raise ImportWarning(
	    """To use `datasets`, the module `pyarrow>=8.0.0` is required, and the current version of `pyarrow` doesn't match this condition.\n"""
	    """If you are running this in a Google Colab, you should probably just restart the runtime to use the right version of `pyarrow`."""
	)

del platform
del pyarrow
del version

from .arrow_dataset import Dataset
from .arrow_reader import ReadInstruction
from .builder import ArrowBasedBuilder, BeamBasedBuilder, BuilderConfig, DatasetBuilder, GeneratorBasedBuilder
from .combine import concatenate_datasets, interleave_datasets
from .dataset_dict import DatasetDict, IterableDatasetDict
from .download import *
from .features import *
from .fingerprint import disable_caching, enable_caching, is_caching_enabled, set_caching_enabled
from .info import DatasetInfo, MetricInfo
from .inspect import (
    get_dataset_config_info,
    get_dataset_config_names,
    get_dataset_infos,
    get_dataset_split_names,
    inspect_dataset,
    inspect_metric,
    list_datasets,
    list_metrics,
)
from .iterable_dataset import IterableDataset
from .load import load_dataset, load_dataset_builder, load_from_disk, load_metric
from .metric import Metric
from .splits import (
    NamedSplit,
    NamedSplitAll,
    Split,
    SplitBase,
    SplitDict,
    SplitGenerator,
    SplitInfo,
    SubSplitInfo,
    percent,
)
from .tasks import *
from .utils import *
from .utils import logging


# deprecated modules
from datasets import arrow_dataset as _arrow_dataset  # isort:skip
from datasets import utils as _utils  # isort:skip
from datasets.utils import download_manager as _deprecated_download_manager  # isort:skip

__lowerCamelCase      :    List[Any]   		=   concatenate_datasets
__lowerCamelCase      :    List[str]   		=   DownloadConfig
__lowerCamelCase      :    Union[str, Any]   		=   DownloadManager
__lowerCamelCase      :    str   		=   DownloadMode
__lowerCamelCase      :    Union[str, Any]   		=   DownloadConfig
__lowerCamelCase      :    List[str]   		=   DownloadMode
__lowerCamelCase      :    Dict   		=   DownloadManager

del _arrow_dataset, _utils, _deprecated_download_manager



