


"""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,
    flip_channel_order,
    get_resize_output_image_size,
    rescale,
    resize,
    to_channel_dimension_format,
)
from ...image_utils import (
    ChannelDimension,
    ImageInput,
    PILImageResampling,
    make_list_of_images,
    to_numpy_array,
    valid_images,
)
from ...utils import TensorType, is_torch_available, is_torch_tensor, is_vision_available, logging


if is_vision_available():
				import PIL

if is_torch_available():
				import torch


__SCREAMING_SNAKE_CASE							:    Union[str, Any]		=    logging.get_logger(__name__)





class      __A     (snake_case__):





							'''simple docstring'''

							__lowercase:		Any							      =    ["""pixel_values"""]



							def __init__(				self							:      List[str]		,       UpperCAmelCase_							:      bool = True		,       UpperCAmelCase_							:      Dict[str, int] = None		,       UpperCAmelCase_							:      PILImageResampling = PILImageResampling.BILINEAR		,       UpperCAmelCase_							:      bool = True		,       UpperCAmelCase_							:      Union[int, float] = 1 / 255		,       UpperCAmelCase_							:      bool = True		,       UpperCAmelCase_							:      Dict[str, int] = None		,       UpperCAmelCase_							:      bool = True		,       **UpperCAmelCase_							:      Tuple		,       )					->None:



														"""simple docstring"""



														super().__init__(**UpperCAmelCase_       )
														snake_case_           =		size if size is not None else {"""shortest_edge""": 224}
														snake_case_           =		get_size_dict(UpperCAmelCase_		,       default_to_square=UpperCAmelCase_       )
														snake_case_           =		crop_size if crop_size is not None else {"""height""": 256, """width""": 256}
														snake_case_           =		get_size_dict(UpperCAmelCase_		,       param_name="""crop_size"""       )

														snake_case_           =		do_resize
														snake_case_           =		size
														snake_case_           =		resample
														snake_case_           =		do_rescale
														snake_case_           =		rescale_factor
														snake_case_           =		do_center_crop
														snake_case_           =		crop_size
														snake_case_           =		do_flip_channel_order



							def 		lowerCAmelCase       (				self							:      Optional[Any]		,       UpperCAmelCase_							:      np.ndarray		,       UpperCAmelCase_							:      Dict[str, int]		,       UpperCAmelCase_							:      PILImageResampling = PIL.Image.BILINEAR		,       UpperCAmelCase_							:      Optional[Union[str, ChannelDimension]] = None		,       **UpperCAmelCase_							:      Union[str, Any]		,       )					->np.ndarray:



														"""simple docstring"""



														snake_case_           =		get_size_dict(UpperCAmelCase_		,       default_to_square=UpperCAmelCase_       )
														if "shortest_edge" not in size:
																					raise ValueError(F"""The `size` dictionary must contain the key `shortest_edge`. Got {size.keys()}"""       )
														snake_case_           =		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 		lowerCAmelCase       (				self							:      List[Any]		,       UpperCAmelCase_							:      np.ndarray		,       UpperCAmelCase_							:      Dict[str, int]		,       UpperCAmelCase_							:      Optional[Union[str, ChannelDimension]] = None		,       **UpperCAmelCase_							:      List[str]		,       )					->np.ndarray:



														"""simple docstring"""



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



							def 		lowerCAmelCase       (				self							:      Optional[int]		,       UpperCAmelCase_							:      np.ndarray		,       UpperCAmelCase_							:      Union[int, float]		,       UpperCAmelCase_							:      Optional[Union[str, ChannelDimension]] = None		,       **UpperCAmelCase_							:      str		,       )					->Optional[int]:



														"""simple docstring"""



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



							def 		lowerCAmelCase       (				self							:      Union[str, Any]		,       UpperCAmelCase_							:      np.ndarray		,       UpperCAmelCase_							:      Optional[Union[str, ChannelDimension]] = None       )					->np.ndarray:



														"""simple docstring"""



														return flip_channel_order(UpperCAmelCase_		,       data_format=UpperCAmelCase_       )



							def 		lowerCAmelCase       (				self							:      List[Any]		,       UpperCAmelCase_							:      ImageInput		,       UpperCAmelCase_							:      bool = None		,       UpperCAmelCase_							:      Dict[str, int] = None		,       UpperCAmelCase_							:      PILImageResampling = None		,       UpperCAmelCase_							:      bool = None		,       UpperCAmelCase_							:      float = None		,       UpperCAmelCase_							:      bool = None		,       UpperCAmelCase_							:      Dict[str, int] = None		,       UpperCAmelCase_							:      bool = None		,       UpperCAmelCase_							:      Optional[Union[str, TensorType]] = None		,       UpperCAmelCase_							:      ChannelDimension = ChannelDimension.FIRST		,       **UpperCAmelCase_							:      Any		,       )					->PIL.Image.Image:



														"""simple docstring"""



														snake_case_           =		do_resize if do_resize is not None else self.do_resize
														snake_case_           =		resample if resample is not None else self.resample
														snake_case_           =		do_rescale if do_rescale is not None else self.do_rescale
														snake_case_           =		rescale_factor if rescale_factor is not None else self.rescale_factor
														snake_case_           =		do_center_crop if do_center_crop is not None else self.do_center_crop
														snake_case_           =		(
														    do_flip_channel_order if do_flip_channel_order is not None else self.do_flip_channel_order
														)

														snake_case_           =		size if size is not None else self.size
														snake_case_           =		get_size_dict(UpperCAmelCase_		,       default_to_square=UpperCAmelCase_       )
														snake_case_           =		crop_size if crop_size is not None else self.crop_size
														snake_case_           =		get_size_dict(UpperCAmelCase_		,       param_name="""crop_size"""       )

														snake_case_           =		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_rescale and rescale_factor is None:
																					raise ValueError("""Rescale factor must be specified if do_rescale is True."""       )

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

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

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

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

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

														# the pretrained checkpoints assume images are BGR, not RGB
														if do_flip_channel_order:
																					snake_case_           =		[self.flip_channel_order(image=UpperCAmelCase_       ) for image in images]

														snake_case_           =		[to_channel_dimension_format(UpperCAmelCase_		,       UpperCAmelCase_       ) for image in images]

														snake_case_           =		{"""pixel_values""": images}
														return BatchFeature(data=UpperCAmelCase_		,       tensor_type=UpperCAmelCase_       )



							def 		lowerCAmelCase       (				self							:      int		,       UpperCAmelCase_							:      Union[str, Any]		,       UpperCAmelCase_							:      List[Tuple] = None       )					->Dict:



														"""simple docstring"""



														snake_case_           =		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_       ):
																												snake_case_           =		target_sizes.numpy()

																					snake_case_           =		[]

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

														return semantic_segmentation







"""simple docstring"""
from __future__ import annotations







def 						_a				(      _SCREAMING_SNAKE_CASE				, _SCREAMING_SNAKE_CASE				)    ->				list[int]:
							snake_case_           =		0
							snake_case_           =		len(_SCREAMING_SNAKE_CASE				) - 1

							while i < j:
														if nums[i] + nums[j] == target:
																					return [i, j]
														elif nums[i] + nums[j] < target:
																					snake_case_           =		i + 1
														else:
																					snake_case_           =		j - 1

							return []


if __name__ == "__main__":
				import doctest

				doctest.testmod()
				print(f"""{two_pointer([2, 7, 11, 15], 9) = }""")



