
"""simple docstring"""

from typing import Dict, List, Optional, Tuple, Union

import numpy as np

from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict
from ...image_transforms import (
    center_crop,
    get_resize_output_image_size,
    normalize,
    rescale,
    resize,
    to_channel_dimension_format,
)
from ...image_utils import (
    IMAGENET_STANDARD_MEAN,
    IMAGENET_STANDARD_STD,
    ChannelDimension,
    ImageInput,
    PILImageResampling,
    make_list_of_images,
    to_numpy_array,
    valid_images,
)
from ...utils import TensorType, is_torch_available, is_torch_tensor, logging


if is_torch_available():
      import torch


UpperCamelCase			:       Optional[Any]									=				logging.get_logger(__name__)

class __lowerCAmelCase	(   _UpperCAmelCase    ):

     '''simple docstring'''





     lowercase		     =		['pixel_values']





     def __init__(			self			,  __UpperCAmelCase = True			,  __UpperCAmelCase = None			,  __UpperCAmelCase = PILImageResampling.BILINEAR			,  __UpperCAmelCase = True			,  __UpperCAmelCase = None			,  __UpperCAmelCase = True			,  __UpperCAmelCase = 1 / 255			,  __UpperCAmelCase = True			,  __UpperCAmelCase = None			,  __UpperCAmelCase = None			,  **__UpperCAmelCase			,  ):

      '''simple docstring'''




      super().__init__(**__UpperCamelCase   )
      __UpperCamelCase       						= size if size is not None else {'shortest_edge': 256}
      __UpperCamelCase       						= get_size_dict(__UpperCamelCase			,  default_to_square=__UpperCamelCase   )
      __UpperCamelCase       						= crop_size if crop_size is not None else {'height': 224, 'width': 224}
      __UpperCamelCase       						= get_size_dict(__UpperCamelCase			,  param_name='crop_size'   )
      __UpperCamelCase       						= do_resize
      __UpperCamelCase       						= size
      __UpperCamelCase       						= resample
      __UpperCamelCase       						= do_center_crop
      __UpperCamelCase       						= crop_size
      __UpperCamelCase       						= do_rescale
      __UpperCamelCase       						= rescale_factor
      __UpperCamelCase       						= do_normalize
      __UpperCamelCase       						= image_mean if image_mean is not None else IMAGENET_STANDARD_MEAN
      __UpperCamelCase       						= image_std if image_std is not None else IMAGENET_STANDARD_STD





     def 		UpperCAmelCase      (			self			,  __UpperCAmelCase			,  __UpperCAmelCase			,  __UpperCAmelCase = PILImageResampling.BICUBIC			,  __UpperCAmelCase = None			,  **__UpperCAmelCase			,  ):

      '''simple docstring'''




      __UpperCamelCase       						= get_size_dict(__UpperCamelCase			,  default_to_square=__UpperCamelCase   )
      if "shortest_edge" not in size:
       raise ValueError(F'The `size` parameter must contain the key `shortest_edge`. Got {size.keys()}'   )
      __UpperCamelCase       						= get_resize_output_image_size(__UpperCamelCase			,  size=size['shortest_edge']			,  default_to_square=__UpperCamelCase   )
      return resize(__UpperCamelCase			,  size=__UpperCamelCase			,  resample=__UpperCamelCase			,  data_format=__UpperCamelCase			,  **__UpperCamelCase   )





     def 		UpperCAmelCase      (			self			,  __UpperCAmelCase			,  __UpperCAmelCase			,  __UpperCAmelCase = None			,  **__UpperCAmelCase			,  ):

      '''simple docstring'''




      __UpperCamelCase       						= get_size_dict(__UpperCamelCase   )
      if "height" not in size or "width" not in size:
       raise ValueError(F'The `size` parameter must contain the keys `height` and `width`. Got {size.keys()}'   )
      return center_crop(__UpperCamelCase			,  size=(size['height'], size['width'])			,  data_format=__UpperCamelCase			,  **__UpperCamelCase   )





     def 		UpperCAmelCase      (			self			,  __UpperCAmelCase			,  __UpperCAmelCase			,  __UpperCAmelCase = None			,  **__UpperCAmelCase   ):

      '''simple docstring'''




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





     def 		UpperCAmelCase      (			self			,  __UpperCAmelCase			,  __UpperCAmelCase			,  __UpperCAmelCase			,  __UpperCAmelCase = None			,  **__UpperCAmelCase			,  ):

      '''simple docstring'''




      return normalize(__UpperCamelCase			,  mean=__UpperCamelCase			,  std=__UpperCamelCase			,  data_format=__UpperCamelCase			,  **__UpperCamelCase   )





     def 		UpperCAmelCase      (			self			,  __UpperCAmelCase			,  __UpperCAmelCase = None			,  __UpperCAmelCase = None			,  __UpperCAmelCase = None			,  __UpperCAmelCase = None			,  __UpperCAmelCase = None			,  __UpperCAmelCase = None			,  __UpperCAmelCase = None			,  __UpperCAmelCase = None			,  __UpperCAmelCase = None			,  __UpperCAmelCase = None			,  __UpperCAmelCase = None			,  __UpperCAmelCase = ChannelDimension.FIRST			,  **__UpperCAmelCase			,  ):

      '''simple docstring'''




      __UpperCamelCase       						= do_resize if do_resize is not None else self.do_resize
      __UpperCamelCase       						= size if size is not None else self.size
      __UpperCamelCase       						= get_size_dict(__UpperCamelCase			,  default_to_square=__UpperCamelCase   )
      __UpperCamelCase       						= resample if resample is not None else self.resample
      __UpperCamelCase       						= do_center_crop if do_center_crop is not None else self.do_center_crop
      __UpperCamelCase       						= crop_size if crop_size is not None else self.crop_size
      __UpperCamelCase       						= get_size_dict(__UpperCamelCase			,  param_name='crop_size'   )
      __UpperCamelCase       						= do_rescale if do_rescale is not None else self.do_rescale
      __UpperCamelCase       						= rescale_factor if rescale_factor is not None else self.rescale_factor
      __UpperCamelCase       						= do_normalize if do_normalize is not None else self.do_normalize
      __UpperCamelCase       						= image_mean if image_mean is not None else self.image_mean
      __UpperCamelCase       						= image_std if image_std is not None else self.image_std

      __UpperCamelCase       						= make_list_of_images(__UpperCamelCase   )

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

      if do_resize and size is None:
       raise ValueError('Size must be specified if do_resize is True.'   )

      if do_center_crop and crop_size is None:
       raise ValueError('Crop size must be specified if do_center_crop is True.'   )

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

      if do_normalize and (image_mean is None or image_std is None):
       raise ValueError('Image mean and std must be specified if do_normalize is True.'   )

      # All transformations expect numpy arrays.
      __UpperCamelCase       						= [to_numpy_array(__UpperCamelCase   ) for image in images]

      if do_resize:
       __UpperCamelCase       						= [self.resize(image=__UpperCamelCase			,  size=__UpperCamelCase			,  resample=__UpperCamelCase   ) for image in images]

      if do_center_crop:
       __UpperCamelCase       						= [self.center_crop(image=__UpperCamelCase			,  size=__UpperCamelCase   ) for image in images]

      if do_rescale:
       __UpperCamelCase       						= [self.rescale(image=__UpperCamelCase			,  scale=__UpperCamelCase   ) for image in images]

      if do_normalize:
       __UpperCamelCase       						= [self.normalize(image=__UpperCamelCase			,  mean=__UpperCamelCase			,  std=__UpperCamelCase   ) for image in images]

      __UpperCamelCase       						= [to_channel_dimension_format(__UpperCamelCase			,  __UpperCamelCase   ) for image in images]

      __UpperCamelCase       						= {'pixel_values': images}
      return BatchFeature(data=__UpperCamelCase			,  tensor_type=__UpperCamelCase   )







     def 		UpperCAmelCase      (			self			,  __UpperCAmelCase			,  __UpperCAmelCase = None   ):

      '''simple docstring'''




      __UpperCamelCase       						= outputs.logits

      # Resize logits and compute semantic segmentation maps
      if target_sizes is not None:
       if len(__UpperCamelCase   ) != len(__UpperCamelCase   ):
        raise ValueError(
            'Make sure that you pass in as many target sizes as the batch dimension of the logits'   )

       if is_torch_tensor(__UpperCamelCase   ):
        __UpperCamelCase       						= target_sizes.numpy()

       __UpperCamelCase       						= []

       for idx in range(len(__UpperCamelCase   )   ):
        __UpperCamelCase       						= torch.nn.functional.interpolate(
            logits[idx].unsqueeze(dim=0   )			,  size=target_sizes[idx]			,  mode='bilinear'			,  align_corners=__UpperCamelCase   )
        __UpperCamelCase       						= resized_logits[0].argmax(dim=0   )
        semantic_segmentation.append(__UpperCamelCase   )
      else:
       __UpperCamelCase       						= logits.argmax(dim=1   )
       __UpperCamelCase       						= [semantic_segmentation[i] for i in range(semantic_segmentation.shape[0]   )]

      return semantic_segmentation





"""simple docstring"""

def 							A		(       snake_case   :int	)   ->			bool:
 return str(snake_case	) == str(snake_case	)[::-1]






def 							A		(       snake_case   :int	)   ->			int:
 return int(snake_case	) + int(str(snake_case	)[::-1]	)






def 							A		(       snake_case   :int = 1_0_0_0_0	)   ->			int:
 __UpperCamelCase       						= []
 for num in range(1       ,      snake_case	):
  __UpperCamelCase       						= 0
  __UpperCamelCase       						= num
  while iterations < 5_0:
   __UpperCamelCase       						= sum_reverse(snake_case	)
   iterations += 1
   if is_palindrome(snake_case	):
    break
  else:
   lychrel_nums.append(snake_case	)
 return len(snake_case	)


if __name__ == "__main__":
      print(f'''{solution() = }''')



