





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 EfficientNetImageProcessor

class 			__A(    unittest.TestCase			):

     def __init__(   self,							A,							A=13,							A=3,							A=18,							A=30,							A=400,							A=True,							A=None,							A=True,							A=[0.5, 0.5, 0.5],							A=[0.5, 0.5, 0.5],							):





            """simple docstring"""

            _UpperCamelCase														=    size if 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_normalize
            _UpperCamelCase														=    image_mean
            _UpperCamelCase														=    image_std



     def 						_UpperCamelCase  (   self   ):





            """simple docstring"""

            return {
                "image_mean": self.image_mean,
                "image_std": self.image_std,
                "do_normalize": self.do_normalize,
                "do_resize": self.do_resize,
                "size": self.size,
            }






@require_torch
@require_vision
class 			__A(    _a    ,      unittest.TestCase			):
     __A							=							EfficientNetImageProcessor if is_vision_available() else None

     def 						_UpperCamelCase  (   self   ):





            """simple docstring"""

            _UpperCamelCase														=    EfficientNetImageProcessorTester(self   )

     @property
     def 						_UpperCamelCase  (   self   ):





            """simple docstring"""

            return self.image_processor_tester.prepare_image_processor_dict()

     def 						_UpperCamelCase  (   self   ):





            """simple docstring"""

            _UpperCamelCase														=    self.image_processing_class(**self.image_processor_dict   )
            self.assertTrue(hasattr(snake_case_,							'''image_mean'''   )   )
            self.assertTrue(hasattr(snake_case_,							'''image_std'''   )   )
            self.assertTrue(hasattr(snake_case_,							'''do_normalize'''   )   )
            self.assertTrue(hasattr(snake_case_,							'''do_resize'''   )   )
            self.assertTrue(hasattr(snake_case_,							'''size'''   )   )

     def 						_UpperCamelCase  (   self   ):





            """simple docstring"""

            _UpperCamelCase														=    self.image_processing_class.from_dict(self.image_processor_dict   )
            self.assertEqual(image_processor.size,							{'''height''': 18, '''width''': 18}   )

            _UpperCamelCase														=    self.image_processing_class.from_dict(self.image_processor_dict,							size=42   )
            self.assertEqual(image_processor.size,							{'''height''': 42, '''width''': 42}   )

     def 						_UpperCamelCase  (   self   ):





            """simple docstring"""

            _UpperCamelCase														=    self.image_processing_class(**self.image_processor_dict   )
            # create random PIL images
            _UpperCamelCase														=    prepare_image_inputs(self.image_processor_tester,							equal_resolution=snake_case_   )
            for image in image_inputs:
                   self.assertIsInstance(snake_case_,							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.size['''height'''],
                    self.image_processor_tester.size['''width'''],
                ),							)

            # Test batched
            _UpperCamelCase														=    image_processing(snake_case_,							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.size['''height'''],
                    self.image_processor_tester.size['''width'''],
                ),							)

     def 						_UpperCamelCase  (   self   ):





            """simple docstring"""

            _UpperCamelCase														=    self.image_processing_class(**self.image_processor_dict   )
            # create random numpy tensors
            _UpperCamelCase														=    prepare_image_inputs(self.image_processor_tester,							equal_resolution=snake_case_,							numpify=snake_case_   )
            for image in image_inputs:
                   self.assertIsInstance(snake_case_,							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.size['''height'''],
                    self.image_processor_tester.size['''width'''],
                ),							)

            # Test batched
            _UpperCamelCase														=    image_processing(snake_case_,							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.size['''height'''],
                    self.image_processor_tester.size['''width'''],
                ),							)



     def 						_UpperCamelCase  (   self   ):





            """simple docstring"""

            _UpperCamelCase														=    self.image_processing_class(**self.image_processor_dict   )
            # create random PyTorch tensors
            _UpperCamelCase														=    prepare_image_inputs(self.image_processor_tester,							equal_resolution=snake_case_,							torchify=snake_case_   )
            for image in image_inputs:
                   self.assertIsInstance(snake_case_,							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.size['''height'''],
                    self.image_processor_tester.size['''width'''],
                ),							)

            # Test batched
            _UpperCamelCase														=    image_processing(snake_case_,							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.size['''height'''],
                    self.image_processor_tester.size['''width'''],
                ),							)














"""simple docstring"""





def 	lowerCAmelCase_(			SCREAMING_SNAKE_CASE       )       ->						int:
    """simple docstring"""

    if not isinstance(SCREAMING_SNAKE_CASE			,						SCREAMING_SNAKE_CASE       ):
        raise ValueError('double_factorial() only accepts integral values'       )
    if num < 0:
        raise ValueError('double_factorial() not defined for negative values'       )
    UpperCamelCase__								=     1
    for i in range(SCREAMING_SNAKE_CASE			,						0			,						-2       ):
        value *= i
    return value


if __name__ == "__main__":
  import doctest

  doctest.testmod()




