




"""simple docstring"""
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 convert_to_rgb, 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


if is_vision_available():
					import PIL


a_				:    Any							=     logging.get_logger(__name__)

class __lowercase(      UpperCAmelCase__				):




					'''simple docstring'''


					__a						:						List[str]     		= ["pixel_values"]
					def __init__(    self						,	__a = True						,	__a = None						,	__a = PILImageResampling.BICUBIC						,	__a = True						,	__a = 1 / 255						,	__a = True						,	__a = None						,	__a = None						,	__a = True						,	**__a						,	):
								super().__init__(**lowerCamelCase__     )
								__lowerCamelCase					:	Optional[int]	       =				size if size is not None else {"height": 384, "width": 384}
								__lowerCamelCase					:	str	       =				get_size_dict(lowerCamelCase__						,	default_to_square=lowerCamelCase__     )

								__lowerCamelCase					:	Dict	       =				do_resize
								__lowerCamelCase					:	List[str]	       =				size
								__lowerCamelCase					:	List[str]	       =				resample
								__lowerCamelCase					:	Optional[Any]	       =				do_rescale
								__lowerCamelCase					:	List[str]	       =				rescale_factor
								__lowerCamelCase					:	Optional[int]	       =				do_normalize
								__lowerCamelCase					:	Union[str, Any]	       =				image_mean if image_mean is not None else OPENAI_CLIP_MEAN
								__lowerCamelCase					:	Tuple	       =				image_std if image_std is not None else OPENAI_CLIP_STD
								__lowerCamelCase					:	Tuple	       =				do_convert_rgb
					def     snake_case_				(    self						,	__a						,	__a						,	__a = PILImageResampling.BICUBIC						,	__a = None						,	**__a						,	):
								__lowerCamelCase					:	Optional[int]	       =				get_size_dict(lowerCamelCase__						,	default_to_square=lowerCamelCase__     )
								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()}'''     )
								__lowerCamelCase					:	Optional[Any]	       =				(size["height"], size["width"])
								return resize(lowerCamelCase__						,	size=lowerCamelCase__						,	resample=lowerCamelCase__						,	data_format=lowerCamelCase__						,	**lowerCamelCase__     )
					def     snake_case_				(    self						,	__a						,	__a						,	__a = None						,	**__a						,	):
								return rescale(lowerCamelCase__						,	scale=lowerCamelCase__						,	data_format=lowerCamelCase__						,	**lowerCamelCase__     )
					def     snake_case_				(    self						,	__a						,	__a						,	__a						,	__a = None						,	**__a						,	):
								return normalize(lowerCamelCase__						,	mean=lowerCamelCase__						,	std=lowerCamelCase__						,	data_format=lowerCamelCase__						,	**lowerCamelCase__     )





					def     snake_case_				(    self						,	__a						,	__a = None						,	__a = None						,	__a = None						,	__a = None						,	__a = None						,	__a = None						,	__a = None						,	__a = None						,	__a = None						,	__a = None						,	__a = ChannelDimension.FIRST						,	**__a						,	):
								__lowerCamelCase					:	Any	       =				do_resize if do_resize is not None else self.do_resize
								__lowerCamelCase					:	Any	       =				resample if resample is not None else self.resample
								__lowerCamelCase					:	Any	       =				do_rescale if do_rescale is not None else self.do_rescale
								__lowerCamelCase					:	Tuple	       =				rescale_factor if rescale_factor is not None else self.rescale_factor
								__lowerCamelCase					:	List[Any]	       =				do_normalize if do_normalize is not None else self.do_normalize
								__lowerCamelCase					:	Union[str, Any]	       =				image_mean if image_mean is not None else self.image_mean
								__lowerCamelCase					:	Dict	       =				image_std if image_std is not None else self.image_std
								__lowerCamelCase					:	Optional[Any]	       =				do_convert_rgb if do_convert_rgb is not None else self.do_convert_rgb

								__lowerCamelCase					:	List[Any]	       =				size if size is not None else self.size
								__lowerCamelCase					:	Dict	       =				get_size_dict(lowerCamelCase__						,	default_to_square=lowerCamelCase__     )

								__lowerCamelCase					:	List[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_resize and size is None or resample is None:
											raise ValueError('Size and resample 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_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					:	List[Any]	       =				[convert_to_rgb(lowerCamelCase__     ) for image in images]

								# All transformations expect numpy arrays.
								__lowerCamelCase					:	Any	       =				[to_numpy_array(lowerCamelCase__     ) for image in images]

								if do_resize:
											__lowerCamelCase					:	Union[str, Any]	       =				[self.resize(image=lowerCamelCase__						,	size=lowerCamelCase__						,	resample=lowerCamelCase__     ) for image in images]

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

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

								__lowerCamelCase					:	List[str]	       =				[to_channel_dimension_format(lowerCamelCase__						,	lowerCamelCase__     ) for image in images]

								__lowerCamelCase					:	List[str]	       =				BatchFeature(data={'pixel_values': images}						,	tensor_type=lowerCamelCase__     )

								return encoded_outputs









"""simple docstring"""
from ...configuration_utils import PretrainedConfig
from ...utils import logging


a_				:    Tuple										=     logging.get_logger(__name__)

a_				:    str										=     {'''openai-gpt''': '''https://huggingface.co/openai-gpt/resolve/main/config.json'''}

class __lowercase(      lowercase__				):




					'''simple docstring'''


					__a						:						Union[str, Any]     		= 'openai-gpt'
					__a						:						List[Any]     		= {
					    'max_position_embeddings': 'n_positions',
					    'hidden_size': 'n_embd',
					    'num_attention_heads': 'n_head',
					    'num_hidden_layers': 'n_layer',
					}
					def __init__(    self						,	__a=40478						,	__a=512						,	__a=768						,	__a=12						,	__a=12						,	__a="gelu"						,	__a=0.1						,	__a=0.1						,	__a=0.1						,	__a=1E-5						,	__a=0.02						,	__a="cls_index"						,	__a=True						,	__a=None						,	__a=True						,	__a=0.1						,	**__a						,	):
								__lowerCamelCase					:	List[str]	       =				vocab_size
								__lowerCamelCase					:	Union[str, Any]	       =				n_positions
								__lowerCamelCase					:	Optional[Any]	       =				n_embd
								__lowerCamelCase					:	int	       =				n_layer
								__lowerCamelCase					:	List[str]	       =				n_head
								__lowerCamelCase					:	Dict	       =				afn
								__lowerCamelCase					:	Optional[Any]	       =				resid_pdrop
								__lowerCamelCase					:	int	       =				embd_pdrop
								__lowerCamelCase					:	int	       =				attn_pdrop
								__lowerCamelCase					:	Dict	       =				layer_norm_epsilon
								__lowerCamelCase					:	List[str]	       =				initializer_range
								__lowerCamelCase					:	Any	       =				summary_type
								__lowerCamelCase					:	Tuple	       =				summary_use_proj
								__lowerCamelCase					:	List[Any]	       =				summary_activation
								__lowerCamelCase					:	str	       =				summary_first_dropout
								__lowerCamelCase					:	Tuple	       =				summary_proj_to_labels
								super().__init__(**__a     )



