




from typing import Dict, List, Optional, Union

import numpy as np

from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict
from ...image_transforms import (
    center_crop,
    convert_to_rgb,
    get_resize_output_image_size,
    normalize,
    rescale,
    resize,
    to_channel_dimension_format,
)
from ...image_utils import (
    OPENAI_CLIP_MEAN,
    OPENAI_CLIP_STD,
    ChannelDimension,
    ImageInput,
    PILImageResampling,
    make_list_of_images,
    to_numpy_array,
    valid_images,
)
from ...utils import TensorType, is_vision_available, logging


_lowerCamelCase      :  Any    						=						logging.get_logger(__name__)


if is_vision_available():
	import PIL
class        __snake_case  (lowercase__		):
				lowerCAmelCase__				=     ['pixel_values']



				def __init__(      self      :		int		,	_UpperCAmelCase      :		str = True		,	_UpperCAmelCase      :		Any = None		,	_UpperCAmelCase      :		Dict = PILImageResampling.BICUBIC		,	_UpperCAmelCase      :		Tuple = True		,	_UpperCAmelCase      :		List[str] = None		,	_UpperCAmelCase      :		List[Any] = True		,	_UpperCAmelCase      :		Tuple = 1 / 255		,	_UpperCAmelCase      :		Optional[int] = True		,	_UpperCAmelCase      :		List[Any] = None		,	_UpperCAmelCase      :		Tuple = None		,	_UpperCAmelCase      :		Union[str, Any] = True		,	**_UpperCAmelCase      :		Any		,	)  ->    Union[str, Any]:





								'''simple docstring'''




								super().__init__(**_UpperCAmelCase      )
								_lowerCAmelCase    :    int										=      size if size is not None else {"""shortest_edge""": 224}
								_lowerCAmelCase    :    Optional[int]										=      get_size_dict(_UpperCAmelCase		,	default_to_square=_UpperCAmelCase      )
								_lowerCAmelCase    :    Optional[Any]										=      crop_size if crop_size is not None else {"""height""": 224, """width""": 224}
								_lowerCAmelCase    :    Dict										=      get_size_dict(_UpperCAmelCase		,	default_to_square=_UpperCAmelCase		,	param_name="""crop_size"""      )

								_lowerCAmelCase    :    Dict										=      do_resize
								_lowerCAmelCase    :    Any										=      size
								_lowerCAmelCase    :    int										=      resample
								_lowerCAmelCase    :    int										=      do_center_crop
								_lowerCAmelCase    :    int										=      crop_size
								_lowerCAmelCase    :    Union[str, Any]										=      do_rescale
								_lowerCAmelCase    :    Any										=      rescale_factor
								_lowerCAmelCase    :    str										=      do_normalize
								_lowerCAmelCase    :    int										=      image_mean if image_mean is not None else OPENAI_CLIP_MEAN
								_lowerCAmelCase    :    List[str]										=      image_std if image_std is not None else OPENAI_CLIP_STD
								_lowerCAmelCase    :    List[str]										=      do_convert_rgb



				def       SCREAMING_SNAKE_CASE       (      self      :		List[str]		,	_UpperCAmelCase      :		Union[str, Any]		,	_UpperCAmelCase      :		int		,	_UpperCAmelCase      :		List[str] = PILImageResampling.BICUBIC		,	_UpperCAmelCase      :		Dict = None		,	**_UpperCAmelCase      :		Dict		,	)  ->    Tuple:





								'''simple docstring'''




								_lowerCAmelCase    :    List[Any]										=      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()}"      )
								_lowerCAmelCase    :    Union[str, Any]										=      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       SCREAMING_SNAKE_CASE       (      self      :		List[Any]		,	_UpperCAmelCase      :		Union[str, Any]		,	_UpperCAmelCase      :		str		,	_UpperCAmelCase      :		str = None		,	**_UpperCAmelCase      :		Union[str, Any]		,	)  ->    List[str]:





								'''simple docstring'''




								_lowerCAmelCase    :    Tuple										=      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, width). Got {size.keys()}"      )
								return center_crop(_UpperCAmelCase		,	size=(size["""height"""], size["""width"""])		,	data_format=_UpperCAmelCase		,	**_UpperCAmelCase      )



				def       SCREAMING_SNAKE_CASE       (      self      :		Optional[int]		,	_UpperCAmelCase      :		Dict		,	_UpperCAmelCase      :		str		,	_UpperCAmelCase      :		int = None		,	**_UpperCAmelCase      :		Optional[int]		,	)  ->    List[str]:





								'''simple docstring'''




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



				def       SCREAMING_SNAKE_CASE       (      self      :		Tuple		,	_UpperCAmelCase      :		Tuple		,	_UpperCAmelCase      :		List[str]		,	_UpperCAmelCase      :		List[Any]		,	_UpperCAmelCase      :		Dict = None		,	**_UpperCAmelCase      :		Optional[int]		,	)  ->    List[str]:





								'''simple docstring'''




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



				def       SCREAMING_SNAKE_CASE       (      self      :		Union[str, Any]		,	_UpperCAmelCase      :		Tuple		,	_UpperCAmelCase      :		Dict = None		,	_UpperCAmelCase      :		List[str] = None		,	_UpperCAmelCase      :		Union[str, Any] = None		,	_UpperCAmelCase      :		Dict = None		,	_UpperCAmelCase      :		Dict = None		,	_UpperCAmelCase      :		List[Any] = None		,	_UpperCAmelCase      :		List[Any] = None		,	_UpperCAmelCase      :		List[Any] = None		,	_UpperCAmelCase      :		Optional[int] = None		,	_UpperCAmelCase      :		Optional[int] = None		,	_UpperCAmelCase      :		int = None		,	_UpperCAmelCase      :		Tuple = None		,	_UpperCAmelCase      :		Tuple = ChannelDimension.FIRST		,	**_UpperCAmelCase      :		Any		,	)  ->    Optional[Any]:





								'''simple docstring'''




								_lowerCAmelCase    :    Any										=      do_resize if do_resize is not None else self.do_resize
								_lowerCAmelCase    :    Optional[int]										=      size if size is not None else self.size
								_lowerCAmelCase    :    List[Any]										=      get_size_dict(_UpperCAmelCase		,	param_name="""size"""		,	default_to_square=_UpperCAmelCase      )
								_lowerCAmelCase    :    List[Any]										=      resample if resample is not None else self.resample
								_lowerCAmelCase    :    Union[str, Any]										=      do_center_crop if do_center_crop is not None else self.do_center_crop
								_lowerCAmelCase    :    Tuple										=      crop_size if crop_size is not None else self.crop_size
								_lowerCAmelCase    :    Union[str, Any]										=      get_size_dict(_UpperCAmelCase		,	param_name="""crop_size"""		,	default_to_square=_UpperCAmelCase      )
								_lowerCAmelCase    :    Any										=      do_rescale if do_rescale is not None else self.do_rescale
								_lowerCAmelCase    :    List[str]										=      rescale_factor if rescale_factor is not None else self.rescale_factor
								_lowerCAmelCase    :    Dict										=      do_normalize if do_normalize is not None else self.do_normalize
								_lowerCAmelCase    :    Tuple										=      image_mean if image_mean is not None else self.image_mean
								_lowerCAmelCase    :    Tuple										=      image_std if image_std is not None else self.image_std
								_lowerCAmelCase    :    Tuple										=      do_convert_rgb if do_convert_rgb is not None else self.do_convert_rgb

								_lowerCAmelCase    :    Tuple										=      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."""      )

								# PIL RGBA images are converted to RGB
								if do_convert_rgb:
												_lowerCAmelCase    :    Optional[int]										=      [convert_to_rgb(_UpperCAmelCase      ) for image in images]

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

								if do_resize:
												_lowerCAmelCase    :    List[Any]										=      [self.resize(image=_UpperCAmelCase		,	size=_UpperCAmelCase		,	resample=_UpperCAmelCase      ) for image in images]

								if do_center_crop:
												_lowerCAmelCase    :    Union[str, Any]										=      [self.center_crop(image=_UpperCAmelCase		,	size=_UpperCAmelCase      ) for image in images]

								if do_rescale:
												_lowerCAmelCase    :    List[str]										=      [self.rescale(image=_UpperCAmelCase		,	scale=_UpperCAmelCase      ) for image in images]

								if do_normalize:
												_lowerCAmelCase    :    Optional[int]										=      [self.normalize(image=_UpperCAmelCase		,	mean=_UpperCAmelCase		,	std=_UpperCAmelCase      ) for image in images]

								_lowerCAmelCase    :    Any										=      [to_channel_dimension_format(_UpperCAmelCase		,	_UpperCAmelCase      ) for image in images]

								_lowerCAmelCase    :    Optional[int]										=      {"""pixel_values""": images}
								return BatchFeature(data=_UpperCAmelCase		,	tensor_type=_UpperCAmelCase      )







def 							_UpperCAmelCase  (UpperCamelCase_ : int       ):
				'''simple docstring'''
				_lowerCAmelCase    :    int										=      n ** (1 / 3)
				return (val * val * val) == n


if __name__ == "__main__":
	print(perfect_cube(2_7))
	print(perfect_cube(4))

