
'''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__   :		List[str]											=	logging.get_logger(__name__)

class  _a					(_lowerCamelCase):





       """simple docstring"""




       SCREAMING_SNAKE_CASE   =	['pixel_values']






       def __init__(				self							,				A__ = True							,				A__ = None							,				A__ = PILImageResampling.BILINEAR							,				A__ = True							,				A__ = None							,				A__ = True							,				A__ = 1 / 2_55							,				A__ = True							,				A__ = None							,				A__ = None							,				**A__							,				)     ->      None:
          super().__init__(**lowerCamelCase__   )
          _SCREAMING_SNAKE_CASE  			=					size if size is not None else {"""shortest_edge""": 2_56}
          _SCREAMING_SNAKE_CASE  			=					get_size_dict(lowerCamelCase__							,				default_to_square=lowerCamelCase__   )
          _SCREAMING_SNAKE_CASE  			=					crop_size if crop_size is not None else {"""height""": 2_24, """width""": 2_24}
          _SCREAMING_SNAKE_CASE  			=					get_size_dict(lowerCamelCase__							,				param_name="""crop_size"""   )
          _SCREAMING_SNAKE_CASE  			=					do_resize
          _SCREAMING_SNAKE_CASE  			=					size
          _SCREAMING_SNAKE_CASE  			=					resample
          _SCREAMING_SNAKE_CASE  			=					do_center_crop
          _SCREAMING_SNAKE_CASE  			=					crop_size
          _SCREAMING_SNAKE_CASE  			=					do_rescale
          _SCREAMING_SNAKE_CASE  			=					rescale_factor
          _SCREAMING_SNAKE_CASE  			=					do_normalize
          _SCREAMING_SNAKE_CASE  			=					image_mean if image_mean is not None else IMAGENET_STANDARD_MEAN
          _SCREAMING_SNAKE_CASE  			=					image_std if image_std is not None else IMAGENET_STANDARD_STD






       def 							UpperCamelCase					(				self							,				A__							,				A__							,				A__ = PILImageResampling.BICUBIC							,				A__ = None							,				**A__							,				)     ->      np.ndarray:
          _SCREAMING_SNAKE_CASE  			=					get_size_dict(lowerCamelCase__							,				default_to_square=lowerCamelCase__   )
          if "shortest_edge" not in size:
             raise ValueError(F"The `size` parameter must contain the key `shortest_edge`. Got {size.keys()}"   )
          _SCREAMING_SNAKE_CASE  			=					get_resize_output_image_size(lowerCamelCase__							,				size=size["""shortest_edge"""]							,				default_to_square=lowerCamelCase__   )
          return resize(lowerCamelCase__							,				size=lowerCamelCase__							,				resample=lowerCamelCase__							,				data_format=lowerCamelCase__							,				**lowerCamelCase__   )






       def 							UpperCamelCase					(				self							,				A__							,				A__							,				A__ = None							,				**A__							,				)     ->      np.ndarray:
          _SCREAMING_SNAKE_CASE  			=					get_size_dict(lowerCamelCase__   )
          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(lowerCamelCase__							,				size=(size["""height"""], size["""width"""])							,				data_format=lowerCamelCase__							,				**lowerCamelCase__   )






       def 							UpperCamelCase					(				self							,				A__							,				A__							,				A__ = None							,				**A__   )     ->      np.ndarray:
          return rescale(lowerCamelCase__							,				scale=lowerCamelCase__							,				data_format=lowerCamelCase__							,				**lowerCamelCase__   )






       def 							UpperCamelCase					(				self							,				A__							,				A__							,				A__							,				A__ = None							,				**A__							,				)     ->      np.ndarray:
          return normalize(lowerCamelCase__							,				mean=lowerCamelCase__							,				std=lowerCamelCase__							,				data_format=lowerCamelCase__							,				**lowerCamelCase__   )






       def 							UpperCamelCase					(				self							,				A__							,				A__ = None							,				A__ = None							,				A__ = None							,				A__ = None							,				A__ = None							,				A__ = None							,				A__ = None							,				A__ = None							,				A__ = None							,				A__ = None							,				A__ = None							,				A__ = ChannelDimension.FIRST							,				**A__							,				)     ->      str:
          _SCREAMING_SNAKE_CASE  			=					do_resize if do_resize is not None else self.do_resize
          _SCREAMING_SNAKE_CASE  			=					size if size is not None else self.size
          _SCREAMING_SNAKE_CASE  			=					get_size_dict(lowerCamelCase__							,				default_to_square=lowerCamelCase__   )
          _SCREAMING_SNAKE_CASE  			=					resample if resample is not None else self.resample
          _SCREAMING_SNAKE_CASE  			=					do_center_crop if do_center_crop is not None else self.do_center_crop
          _SCREAMING_SNAKE_CASE  			=					crop_size if crop_size is not None else self.crop_size
          _SCREAMING_SNAKE_CASE  			=					get_size_dict(lowerCamelCase__							,				param_name="""crop_size"""   )
          _SCREAMING_SNAKE_CASE  			=					do_rescale if do_rescale is not None else self.do_rescale
          _SCREAMING_SNAKE_CASE  			=					rescale_factor if rescale_factor is not None else self.rescale_factor
          _SCREAMING_SNAKE_CASE  			=					do_normalize if do_normalize is not None else self.do_normalize
          _SCREAMING_SNAKE_CASE  			=					image_mean if image_mean is not None else self.image_mean
          _SCREAMING_SNAKE_CASE  			=					image_std if image_std is not None else self.image_std

          _SCREAMING_SNAKE_CASE  			=					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_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.
          _SCREAMING_SNAKE_CASE  			=					[to_numpy_array(lowerCamelCase__   ) for image in images]

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

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

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

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

          _SCREAMING_SNAKE_CASE  			=					[to_channel_dimension_format(lowerCamelCase__							,				lowerCamelCase__   ) for image in images]

          _SCREAMING_SNAKE_CASE  			=					{"""pixel_values""": images}
          return BatchFeature(data=lowerCamelCase__							,				tensor_type=lowerCamelCase__   )






       def 							UpperCamelCase					(				self							,				A__							,				A__ = None   )     ->      Optional[Any]:
          _SCREAMING_SNAKE_CASE  			=					outputs.logits

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

             if is_torch_tensor(lowerCamelCase__   ):
                _SCREAMING_SNAKE_CASE  			=					target_sizes.numpy()

             _SCREAMING_SNAKE_CASE  			=					[]

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

          return semantic_segmentation












from string import ascii_uppercase

__A								=       {str(ord(c) - 55): c for c in ascii_uppercase}







def      lowerCamelCase_						(			UpperCamelCase__							: int					,	UpperCamelCase__							: int )	->			str:





				"""simple docstring"""


				if isinstance(UpperCamelCase__					,	UpperCamelCase__ ):
								raise TypeError('int() can\'t convert non-string with explicit base' )
				if num < 0:
								raise ValueError('parameter must be positive int' )
				if isinstance(UpperCamelCase__					,	UpperCamelCase__ ):
								raise TypeError('\'str\' object cannot be interpreted as an integer' )
				if isinstance(UpperCamelCase__					,	UpperCamelCase__ ):
								raise TypeError('\'float\' object cannot be interpreted as an integer' )
				if base in (0, 1):
								raise ValueError('base must be >= 2' )
				if base > 36:
								raise ValueError('base must be <= 36' )
				__lowerCamelCase									=       ''
				__lowerCamelCase									=       0
				__lowerCamelCase									=       0
				while div != 1:
								__lowerCamelCase			,		__lowerCamelCase									=       divmod(UpperCamelCase__					,	UpperCamelCase__ )
								if base >= 11 and 9 < mod < 36:
												__lowerCamelCase									=       ALPHABET_VALUES[str(UpperCamelCase__ )]
								else:
												__lowerCamelCase									=       str(UpperCamelCase__ )
								new_value += actual_value
								__lowerCamelCase									=       num // base
								__lowerCamelCase									=       div
								if div == 0:
												return str(new_value[::-1] )
								elif div == 1:
												new_value += str(UpperCamelCase__ )
												return str(new_value[::-1] )

				return new_value[::-1]


if __name__ == "__main__":
					import doctest

					doctest.testmod()

					for base in range(2, 37):
										for num in range(10_00):
															assert int(decimal_to_any(num, base), base) == num, (
															    num,
															    base,
															    decimal_to_any(num, base),
															    int(decimal_to_any(num, base), base),
															)


