'''simple docstring'''

from typing import Optional, Union

import numpy as np

from ...image_processing_utils import BaseImageProcessor, BatchFeature
from ...image_transforms import get_image_size, pad, rescale, to_channel_dimension_format
from ...image_utils import ChannelDimension, ImageInput, make_list_of_images, to_numpy_array, valid_images
from ...utils import TensorType, logging


UpperCamelCase__     :	Optional[int]				=			logging.get_logger(__name__)


class 				_lowercase	(      lowerCAmelCase   ):
      '''simple docstring'''


      UpperCAmelCase_      :      Union[str, Any]      							=   ['''pixel_values''']




      def __init__(				self					,lowerCamelCase_ = True					,lowerCamelCase_ = 1 / 255					,lowerCamelCase_ = True					,lowerCamelCase_ = 8					,**lowerCamelCase_					,)			->			None:



         '''simple docstring'''



         super().__init__(**lowerCamelCase_							)

         UpperCAmelCase__							:				Dict   				=  do_rescale
         UpperCAmelCase__							:				int   				=  rescale_factor
         UpperCAmelCase__							:				Tuple   				=  do_pad
         UpperCAmelCase__							:				List[str]   				=  pad_size




      def 		lowerCAmelCase__					(				self					,lowerCamelCase_					,lowerCamelCase_					,lowerCamelCase_ = None					,**lowerCamelCase_							)			->			np.ndarray:



         '''simple docstring'''



         return rescale(lowerCamelCase_					,scale=lowerCamelCase_					,data_format=lowerCamelCase_					,**lowerCamelCase_							)




      def 		lowerCAmelCase__					(				self					,lowerCamelCase_					,lowerCamelCase_					,lowerCamelCase_ = None							)			->			Union[str, Any]:



         '''simple docstring'''



         UpperCAmelCase__				,      UpperCAmelCase__							:				Tuple   				=  get_image_size(lowerCamelCase_							)
         UpperCAmelCase__							:				Union[str, Any]   				=  (old_height // size + 1) * size - old_height
         UpperCAmelCase__							:				List[str]   				=  (old_width // size + 1) * size - old_width

         return pad(lowerCamelCase_					,((0, pad_height), (0, pad_width))					,mode='''symmetric'''					,data_format=lowerCamelCase_							)




      def 		lowerCAmelCase__					(				self					,lowerCamelCase_					,lowerCamelCase_ = None					,lowerCamelCase_ = None					,lowerCamelCase_ = None					,lowerCamelCase_ = None					,lowerCamelCase_ = None					,lowerCamelCase_ = ChannelDimension.FIRST					,**lowerCamelCase_					,)			->			Any:



         '''simple docstring'''



         UpperCAmelCase__							:				int   				=  do_rescale if do_rescale is not None else self.do_rescale
         UpperCAmelCase__							:				Optional[Any]   				=  rescale_factor if rescale_factor is not None else self.rescale_factor
         UpperCAmelCase__							:				str   				=  do_pad if do_pad is not None else self.do_pad
         UpperCAmelCase__							:				Optional[int]   				=  pad_size if pad_size is not None else self.pad_size

         UpperCAmelCase__							:				Union[str, Any]   				=  make_list_of_images(lowerCamelCase_							)

         if not valid_images(lowerCamelCase_							):
            raise ValueError(
                '''Invalid image type. Must be of type PIL.Image.Image, numpy.ndarray, '''
                '''torch.Tensor, tf.Tensor or jax.ndarray.'''							)

         if do_rescale and rescale_factor is None:
            raise ValueError('''Rescale factor must be specified if do_rescale is True.'''							)

         # All transformations expect numpy arrays.
         UpperCAmelCase__							:				Dict   				=  [to_numpy_array(lowerCamelCase_							) for image in images]

         if do_rescale:
            UpperCAmelCase__							:				Optional[Any]   				=  [self.rescale(image=lowerCamelCase_					,scale=lowerCamelCase_							) for image in images]

         if do_pad:
            UpperCAmelCase__							:				Tuple   				=  [self.pad(lowerCamelCase_					,size=lowerCamelCase_							) for image in images]

         UpperCAmelCase__							:				Tuple   				=  [to_channel_dimension_format(lowerCamelCase_					,lowerCamelCase_							) for image in images]

         UpperCAmelCase__							:				Union[str, Any]   				=  {'''pixel_values''': images}
         return BatchFeature(data=lowerCamelCase_					,tensor_type=lowerCamelCase_							)





'''simple docstring'''

def __UpperCamelCase(   _A					:				int    ):
   '''simple docstring'''

   if length <= 0 or not isinstance(_A  ,			_A    ):
      raise ValueError('''Length must be a positive integer.'''    )
   return [n * (2 * n - 1) for n in range(_A    )]


if __name__ == "__main__":
  print(hexagonal_numbers(length=5))
  print(hexagonal_numbers(length=10))




