






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




class 					__UpperCAmelCase (		unittest.TestCase	):

      '''simple docstring'''





      def __init__(					self  ,		_UpperCAmelCase  ,		_UpperCAmelCase=7  ,		_UpperCAmelCase=3  ,		_UpperCAmelCase=18  ,		_UpperCAmelCase=30  ,		_UpperCAmelCase=400  ,		_UpperCAmelCase=True  ,		_UpperCAmelCase=None  ,		_UpperCAmelCase=0.8_75  ,		_UpperCAmelCase=True  ,		_UpperCAmelCase=[0.5, 0.5, 0.5]  ,		_UpperCAmelCase=[0.5, 0.5, 0.5]  ,		):
             UpperCAmelCase__	:   int												=	size if size is not None else {'''shortest_edge''': 20}
             UpperCAmelCase__	:   List[Any]												=	parent
             UpperCAmelCase__	:   int												=	batch_size
             UpperCAmelCase__	:   Union[str, Any]												=	num_channels
             UpperCAmelCase__	:   Optional[int]												=	image_size
             UpperCAmelCase__	:   List[str]												=	min_resolution
             UpperCAmelCase__	:   str												=	max_resolution
             UpperCAmelCase__	:   Optional[int]												=	do_resize
             UpperCAmelCase__	:   Any												=	size
             UpperCAmelCase__	:   Optional[Any]												=	crop_pct
             UpperCAmelCase__	:   Optional[Any]												=	do_normalize
             UpperCAmelCase__	:   Union[str, Any]												=	image_mean
             UpperCAmelCase__	:   Optional[int]												=	image_std




      def 							lowerCamelCase     (					self						):
             return {
                 "image_mean": self.image_mean,
                 "image_std": self.image_std,
                 "do_normalize": self.do_normalize,
                 "do_resize": self.do_resize,
                 "size": self.size,
                 "crop_pct": self.crop_pct,
             }




@require_torch
@require_vision
class 					__UpperCAmelCase (		__lowerCAmelCase      ,				unittest.TestCase	):

      '''simple docstring'''





      SCREAMING_SNAKE_CASE				:    Any				       =					ConvNextImageProcessor if is_vision_available() else None




      def 							lowerCamelCase     (					self						):
             UpperCAmelCase__	:   Any												=	ConvNextImageProcessingTester(self						)




      @property
      def 							lowerCamelCase     (					self						):
             return self.image_processor_tester.prepare_image_processor_dict()




      def 							lowerCamelCase     (					self						):
             UpperCAmelCase__	:   Optional[int]												=	self.image_processing_class(**self.image_processor_dict						)
             self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE  ,		'''do_resize'''						)						)
             self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE  ,		'''size'''						)						)
             self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE  ,		'''crop_pct'''						)						)
             self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE  ,		'''do_normalize'''						)						)
             self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE  ,		'''image_mean'''						)						)
             self.assertTrue(hasattr(__SCREAMING_SNAKE_CASE  ,		'''image_std'''						)						)




      def 							lowerCamelCase     (					self						):
             UpperCAmelCase__	:   Any												=	self.image_processing_class.from_dict(self.image_processor_dict						)
             self.assertEqual(image_processor.size  ,		{'''shortest_edge''': 20}						)

             UpperCAmelCase__	:   List[Any]												=	self.image_processing_class.from_dict(self.image_processor_dict  ,		size=42						)
             self.assertEqual(image_processor.size  ,		{'''shortest_edge''': 42}						)




      def 							lowerCamelCase     (					self						):
             pass




      def 							lowerCamelCase     (					self						):
             UpperCAmelCase__	:   Tuple												=	self.image_processing_class(**self.image_processor_dict						)
             # create random PIL images
             UpperCAmelCase__	:   Tuple												=	prepare_image_inputs(self.image_processor_tester  ,		equal_resolution=__SCREAMING_SNAKE_CASE						)
             for image in image_inputs:
                    self.assertIsInstance(__SCREAMING_SNAKE_CASE  ,		Image.Image						)

             # Test not batched input
             UpperCAmelCase__	:   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.size['''shortest_edge'''],
                     self.image_processor_tester.size['''shortest_edge'''],
                 )  ,		)

             # Test batched
             UpperCAmelCase__	:   Union[str, Any]												=	image_processing(__SCREAMING_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['''shortest_edge'''],
                     self.image_processor_tester.size['''shortest_edge'''],
                 )  ,		)




      def 							lowerCamelCase     (					self						):
             UpperCAmelCase__	:   Tuple												=	self.image_processing_class(**self.image_processor_dict						)
             # create random numpy tensors
             UpperCAmelCase__	:   int												=	prepare_image_inputs(self.image_processor_tester  ,		equal_resolution=__SCREAMING_SNAKE_CASE  ,		numpify=__SCREAMING_SNAKE_CASE						)
             for image in image_inputs:
                    self.assertIsInstance(__SCREAMING_SNAKE_CASE  ,		np.ndarray						)

             # Test not batched input
             UpperCAmelCase__	:   Optional[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.size['''shortest_edge'''],
                     self.image_processor_tester.size['''shortest_edge'''],
                 )  ,		)

             # Test batched
             UpperCAmelCase__	:   List[str]												=	image_processing(__SCREAMING_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['''shortest_edge'''],
                     self.image_processor_tester.size['''shortest_edge'''],
                 )  ,		)




      def 							lowerCamelCase     (					self						):
             UpperCAmelCase__	:   Union[str, Any]												=	self.image_processing_class(**self.image_processor_dict						)
             # create random PyTorch tensors
             UpperCAmelCase__	:   Tuple												=	prepare_image_inputs(self.image_processor_tester  ,		equal_resolution=__SCREAMING_SNAKE_CASE  ,		torchify=__SCREAMING_SNAKE_CASE						)
             for image in image_inputs:
                    self.assertIsInstance(__SCREAMING_SNAKE_CASE  ,		torch.Tensor						)

             # Test not batched input
             UpperCAmelCase__	:   Optional[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.size['''shortest_edge'''],
                     self.image_processor_tester.size['''shortest_edge'''],
                 )  ,		)

             # Test batched
             UpperCAmelCase__	:   Dict												=	image_processing(__SCREAMING_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['''shortest_edge'''],
                     self.image_processor_tester.size['''shortest_edge'''],
                 )  ,		)






"""simple docstring"""


def 				a__      (	_UpperCAmelCase						,  _UpperCAmelCase						,  _UpperCAmelCase						)     ->	float:

 '''simple docstring'''






 snake_case__     				=					[1 / first_term]
 snake_case__     				=					1 / first_term
 for _ in range(number_of_terms - 1						):
  first_term += common_difference
  arithmetic_progression.append(_UpperCAmelCase						)
 snake_case__     				=					[1 / step for step in arithmetic_progression]
 return sum(_UpperCAmelCase						)


if __name__ == "__main__":
   import doctest

   doctest.testmod()
   print(sum_of_harmonic_progression(1 / 2, 2, 2))

