"""simple docstring"""






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 				snake_case       ( unittest.TestCase				):




					"""simple docstring"""

					def __init__(				self   :	List[str]    ,lowerCamelCase__   :	List[Any]    ,lowerCamelCase__   :	List[Any]=7    ,lowerCamelCase__   :	Dict=3    ,lowerCamelCase__   :	Any=18    ,lowerCamelCase__   :	List[str]=30    ,lowerCamelCase__   :	int=400    ,lowerCamelCase__   :	Optional[Any]=True    ,lowerCamelCase__   :	Any=None    ,lowerCamelCase__   :	str=True    ,lowerCamelCase__   :	Union[str, Any]=None    ,lowerCamelCase__   :	Any=True    ,):
									UpperCAmelCase__             =							size if size is not None else {'shortest_edge': 20}
									UpperCAmelCase__             =							crop_size if crop_size is not None else {'height': 18, 'width': 18}
									UpperCAmelCase__             =							parent
									UpperCAmelCase__             =							batch_size
									UpperCAmelCase__             =							num_channels
									UpperCAmelCase__             =							image_size
									UpperCAmelCase__             =							min_resolution
									UpperCAmelCase__             =							max_resolution
									UpperCAmelCase__             =							do_resize
									UpperCAmelCase__             =							size
									UpperCAmelCase__             =							do_center_crop
									UpperCAmelCase__             =							crop_size
									UpperCAmelCase__             =							do_flip_channel_order







					def 		__lowerCAmelCase						(				self   :	List[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 				snake_case       ( snake_case__      ,    unittest.TestCase				):




					"""simple docstring"""

					snake_case__				    = MobileViTImageProcessor if is_vision_available() else None







					def 		__lowerCAmelCase						(				self   :	Union[str, Any]			):
									UpperCAmelCase__             =							MobileViTImageProcessingTester(self			)







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







					def 		__lowerCAmelCase						(				self   :	Any			):
									UpperCAmelCase__             =							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 		__lowerCAmelCase						(				self   :	Dict			):
									UpperCAmelCase__             =							self.image_processing_class.from_dict(self.image_processor_dict			)
									self.assertEqual(image_processor.size    ,{'shortest_edge': 20}			)
									self.assertEqual(image_processor.crop_size    ,{'height': 18, 'width': 18}			)

									UpperCAmelCase__             =							self.image_processing_class.from_dict(self.image_processor_dict    ,size=42    ,crop_size=84			)
									self.assertEqual(image_processor.size    ,{'shortest_edge': 42}			)
									self.assertEqual(image_processor.crop_size    ,{'height': 84, 'width': 84}			)







					def 		__lowerCAmelCase						(				self   :	Any			):
									pass







					def 		__lowerCAmelCase						(				self   :	Union[str, Any]			):
									# Initialize image_processing
									UpperCAmelCase__             =							self.image_processing_class(**self.image_processor_dict			)
									# create random PIL images
									UpperCAmelCase__             =							prepare_image_inputs(self.image_processor_tester    ,equal_resolution=_A			)
									for image in image_inputs:
													self.assertIsInstance(_A    ,Image.Image			)

									# Test not batched input
									UpperCAmelCase__             =							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
									UpperCAmelCase__             =							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 		__lowerCAmelCase						(				self   :	Dict			):
									# Initialize image_processing
									UpperCAmelCase__             =							self.image_processing_class(**self.image_processor_dict			)
									# create random numpy tensors
									UpperCAmelCase__             =							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
									UpperCAmelCase__             =							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
									UpperCAmelCase__             =							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 		__lowerCAmelCase						(				self   :	Tuple			):
									# Initialize image_processing
									UpperCAmelCase__             =							self.image_processing_class(**self.image_processor_dict			)
									# create random PyTorch tensors
									UpperCAmelCase__             =							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
									UpperCAmelCase__             =							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
									UpperCAmelCase__             =							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'],
									    )    ,)










from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_torch_available,
)


UpperCAmelCase						:   Any			  =     {
    '''configuration_falcon''': ['''FALCON_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''FalconConfig'''],
}

try:
				if not is_torch_available():
								raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
				pass
else:
				UpperCAmelCase						:   Any			  =     [
				    '''FALCON_PRETRAINED_MODEL_ARCHIVE_LIST''',
				    '''FalconForCausalLM''',
				    '''FalconModel''',
				    '''FalconPreTrainedModel''',
				    '''FalconForSequenceClassification''',
				    '''FalconForTokenClassification''',
				    '''FalconForQuestionAnswering''',
				]


if TYPE_CHECKING:
				from .configuration_falcon import FALCON_PRETRAINED_CONFIG_ARCHIVE_MAP, FalconConfig

				try:
								if not is_torch_available():
												raise OptionalDependencyNotAvailable()
				except OptionalDependencyNotAvailable:
								pass
				else:
								from .modeling_falcon import (
								    FALCON_PRETRAINED_MODEL_ARCHIVE_LIST,
								    FalconForCausalLM,
								    FalconForQuestionAnswering,
								    FalconForSequenceClassification,
								    FalconForTokenClassification,
								    FalconModel,
								    FalconPreTrainedModel,
								)


else:
				import sys

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




