


'''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 ViTImageProcessor




class 						a__							(				unittest.TestCase    ):





							'''simple docstring'''






							def __init__(						self   ,       lowerCamelCase_   ,       lowerCamelCase_=13   ,       lowerCamelCase_=3   ,       lowerCamelCase_=2_24   ,       lowerCamelCase_=30   ,       lowerCamelCase_=4_00   ,       lowerCamelCase_=True   ,       lowerCamelCase_=None   ,       lowerCamelCase_=True   ,       lowerCamelCase_=[0.5, 0.5, 0.5]   ,       lowerCamelCase_=[0.5, 0.5, 0.5]   ,       )			->				Any:
														lowerCAmelCase__			  =      size if size is not None else {'''height''': 18, '''width''': 18}
														lowerCAmelCase__			  =      parent
														lowerCAmelCase__			  =      batch_size
														lowerCAmelCase__			  =      num_channels
														lowerCAmelCase__			  =      image_size
														lowerCAmelCase__			  =      min_resolution
														lowerCAmelCase__			  =      max_resolution
														lowerCAmelCase__			  =      do_resize
														lowerCAmelCase__			  =      size
														lowerCAmelCase__			  =      do_normalize
														lowerCAmelCase__			  =      image_mean
														lowerCAmelCase__			  =      image_std







							def     __SCREAMING_SNAKE_CASE				(						self  )			->				List[str]:
														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    ):





							'''simple docstring'''






							lowercase__     :  int      		= ViTImageProcessor if is_vision_available() else None







							def     __SCREAMING_SNAKE_CASE				(						self  )			->				List[str]:
														lowerCAmelCase__			  =      EfficientFormerImageProcessorTester(self  )







							@property
							def     __SCREAMING_SNAKE_CASE				(						self  )			->				List[Any]:
														return self.image_proc_tester.prepare_image_processor_dict()







							def     __SCREAMING_SNAKE_CASE				(						self  )			->				Optional[Any]:
														lowerCAmelCase__			  =      self.image_processing_class(**self.image_processor_dict  )
														self.assertTrue(hasattr(lowerCamelCase_   ,       '''image_mean'''  )  )
														self.assertTrue(hasattr(lowerCamelCase_   ,       '''image_std'''  )  )
														self.assertTrue(hasattr(lowerCamelCase_   ,       '''do_normalize'''  )  )
														self.assertTrue(hasattr(lowerCamelCase_   ,       '''do_resize'''  )  )
														self.assertTrue(hasattr(lowerCamelCase_   ,       '''size'''  )  )







							def     __SCREAMING_SNAKE_CASE				(						self  )			->				Optional[Any]:
														pass







							def     __SCREAMING_SNAKE_CASE				(						self  )			->				List[Any]:
														# Initialize image_processor
														lowerCAmelCase__			  =      self.image_processing_class(**self.image_processor_dict  )
														# create random PIL images
														lowerCAmelCase__			  =      prepare_image_inputs(self.image_proc_tester   ,       equal_resolution=lowerCamelCase_  )
														for image in image_inputs:
																					self.assertIsInstance(lowerCamelCase_   ,       Image.Image  )

														# Test not batched input
														lowerCAmelCase__			  =      image_processor(image_inputs[0]   ,       return_tensors='''pt'''  ).pixel_values
														self.assertEqual(
														    encoded_images.shape   ,       (
														        1,
														        self.image_proc_tester.num_channels,
														        self.image_proc_tester.size['''height'''],
														        self.image_proc_tester.size['''width'''],
														    )   ,       )

														# Test batched
														lowerCAmelCase__			  =      image_processor(lowerCamelCase_   ,       return_tensors='''pt'''  ).pixel_values
														self.assertEqual(
														    encoded_images.shape   ,       (
														        self.image_proc_tester.batch_size,
														        self.image_proc_tester.num_channels,
														        self.image_proc_tester.size['''height'''],
														        self.image_proc_tester.size['''width'''],
														    )   ,       )







							def     __SCREAMING_SNAKE_CASE				(						self  )			->				str:
														# Initialize image_processor
														lowerCAmelCase__			  =      self.image_processing_class(**self.image_processor_dict  )
														# create random numpy tensors
														lowerCAmelCase__			  =      prepare_image_inputs(self.image_proc_tester   ,       equal_resolution=lowerCamelCase_   ,       numpify=lowerCamelCase_  )
														for image in image_inputs:
																					self.assertIsInstance(lowerCamelCase_   ,       np.ndarray  )

														# Test not batched input
														lowerCAmelCase__			  =      image_processor(image_inputs[0]   ,       return_tensors='''pt'''  ).pixel_values
														self.assertEqual(
														    encoded_images.shape   ,       (
														        1,
														        self.image_proc_tester.num_channels,
														        self.image_proc_tester.size['''height'''],
														        self.image_proc_tester.size['''width'''],
														    )   ,       )

														# Test batched
														lowerCAmelCase__			  =      image_processor(lowerCamelCase_   ,       return_tensors='''pt'''  ).pixel_values
														self.assertEqual(
														    encoded_images.shape   ,       (
														        self.image_proc_tester.batch_size,
														        self.image_proc_tester.num_channels,
														        self.image_proc_tester.size['''height'''],
														        self.image_proc_tester.size['''width'''],
														    )   ,       )







							def     __SCREAMING_SNAKE_CASE				(						self  )			->				Dict:
														# Initialize image_processor
														lowerCAmelCase__			  =      self.image_processing_class(**self.image_processor_dict  )
														# create random PyTorch tensors
														lowerCAmelCase__			  =      prepare_image_inputs(self.image_proc_tester   ,       equal_resolution=lowerCamelCase_   ,       torchify=lowerCamelCase_  )
														for image in image_inputs:
																					self.assertIsInstance(lowerCamelCase_   ,       torch.Tensor  )

														# Test not batched input
														lowerCAmelCase__			  =      image_processor(image_inputs[0]   ,       return_tensors='''pt'''  ).pixel_values
														self.assertEqual(
														    encoded_images.shape   ,       (
														        1,
														        self.image_proc_tester.num_channels,
														        self.image_proc_tester.size['''height'''],
														        self.image_proc_tester.size['''width'''],
														    )   ,       )

														# Test batched
														lowerCAmelCase__			  =      image_processor(lowerCamelCase_   ,       return_tensors='''pt'''  ).pixel_values
														self.assertEqual(
														    encoded_images.shape   ,       (
														        self.image_proc_tester.batch_size,
														        self.image_proc_tester.num_channels,
														        self.image_proc_tester.size['''height'''],
														        self.image_proc_tester.size['''width'''],
														    )   ,       )



'''simple docstring'''






from collections.abc import Callable

import numpy as np


def    _snake_case  (	A					,       A					,       A					,       A					,       A			)		->       np.array:
							lowerCAmelCase__			  =      int(np.ceil((x_end - xa) / step_size			)			)
							lowerCAmelCase__			  =      np.zeros((n + 1,)			)
							lowerCAmelCase__			  =      ya
							lowerCAmelCase__			  =      xa

							for k in range(A			):
														lowerCAmelCase__			  =      y[k] + step_size * ode_func(A					,       y[k]			)
														lowerCAmelCase__			  =      y[k] + (
														    (step_size / 2) * (ode_func(A					,       y[k]			) + ode_func(x + step_size					,       A			))
														)
														x += step_size

							return y


if __name__ == "__main__":
		import doctest

		doctest.testmod()