



"""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 (
    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,
    is_valid_image,
    to_numpy_array,
    valid_images,
)
from ...utils import TensorType, is_vision_available, logging


if is_vision_available():
					import PIL


A   =       logging.get_logger(__name__)

def 					_UpperCamelCase    (			UpperCamelCase							)			->			Dict:


			"""simple docstring"""






			if isinstance(UpperCAmelCase__				,       (list, tuple)							) and isinstance(videos[0]				,       (list, tuple)							) and is_valid_image(videos[0][0]							):
						return videos

			elif isinstance(UpperCAmelCase__				,       (list, tuple)							) and is_valid_image(videos[0]							):
						return [videos]

			elif is_valid_image(UpperCAmelCase__							):
						return [[videos]]

			raise ValueError(f"Could not make batched video from {videos}"							)





class      a__				(	_a   ):
			lowercase_    =	["pixel_values"]


			def __init__(      self      :    Any      ,  UpperCamelCase_      :    List[Any] = True      ,  UpperCamelCase_      :    Tuple = None      ,  UpperCamelCase_      :    str = PILImageResampling.BILINEAR      ,  UpperCamelCase_      :    Any = True      ,  UpperCamelCase_      :    str = None      ,  UpperCamelCase_      :    Dict = True      ,  UpperCamelCase_      :    Any = 1 / 255      ,  UpperCamelCase_      :    List[Any] = True      ,  UpperCamelCase_      :    Any = None      ,  UpperCamelCase_      :    List[Any] = None      ,  **UpperCamelCase_      :    Optional[Any]      ,  ):


						"""simple docstring"""




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

						__UpperCAmelCase	: List[str]		=					do_resize
						__UpperCAmelCase	: int		=					size
						__UpperCAmelCase	: Union[str, Any]		=					do_center_crop
						__UpperCAmelCase	: Optional[Any]		=					crop_size
						__UpperCAmelCase	: str		=					resample
						__UpperCAmelCase	: Optional[Any]		=					do_rescale
						__UpperCAmelCase	: Union[str, Any]		=					rescale_factor
						__UpperCAmelCase	: Union[str, Any]		=					do_normalize
						__UpperCAmelCase	: Optional[Any]		=					image_mean if image_mean is not None else IMAGENET_STANDARD_MEAN
						__UpperCAmelCase	: Tuple		=					image_std if image_std is not None else IMAGENET_STANDARD_STD


			def       a_     (      self      :    Optional[Any]      ,  UpperCamelCase_      :    List[Any]      ,  UpperCamelCase_      :    Any      ,  UpperCamelCase_      :    Optional[int] = PILImageResampling.BILINEAR      ,  UpperCamelCase_      :    Union[str, Any] = None      ,  **UpperCamelCase_      :    Optional[Any]      ,  ):


						"""simple docstring"""




						__UpperCAmelCase	: Tuple		=					get_size_dict(_A      ,  default_to_square=_A)
						if "shortest_edge" in size:
									__UpperCAmelCase	: Optional[Any]		=					get_resize_output_image_size(_A      ,  size["shortest_edge"]      ,  default_to_square=_A)
						elif "height" in size and "width" in size:
									__UpperCAmelCase	: Dict		=					(size["height"], size["width"])
						else:
									raise ValueError(F"Size must have 'height' and 'width' or 'shortest_edge' as keys. Got {size.keys()}")
						return resize(_A      ,  size=_A      ,  resample=_A      ,  data_format=_A      ,  **_A)


			def       a_     (      self      :    List[str]      ,  UpperCamelCase_      :    Optional[Any]      ,  UpperCamelCase_      :    Any      ,  UpperCamelCase_      :    List[str] = None      ,  **UpperCamelCase_      :    List[str]      ,  ):


						"""simple docstring"""




						__UpperCAmelCase	: List[str]		=					get_size_dict(_A)
						if "height" not in size or "width" not in size:
									raise ValueError(F"Size must have 'height' and 'width' as keys. Got {size.keys()}")
						return center_crop(_A      ,  size=(size["height"], size["width"])      ,  data_format=_A      ,  **_A)


			def       a_     (      self      :    Union[str, Any]      ,  UpperCamelCase_      :    Union[str, Any]      ,  UpperCamelCase_      :    str      ,  UpperCamelCase_      :    List[Any] = None      ,  **UpperCamelCase_      :    Tuple      ,  ):


						"""simple docstring"""




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


			def       a_     (      self      :    Union[str, Any]      ,  UpperCamelCase_      :    Tuple      ,  UpperCamelCase_      :    Dict      ,  UpperCamelCase_      :    int      ,  UpperCamelCase_      :    Dict = None      ,  **UpperCamelCase_      :    Tuple      ,  ):


						"""simple docstring"""




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


			def       a_     (      self      :    Dict      ,  UpperCamelCase_      :    Union[str, Any]      ,  UpperCamelCase_      :    Optional[Any] = None      ,  UpperCamelCase_      :    Any = None      ,  UpperCamelCase_      :    List[str] = None      ,  UpperCamelCase_      :    Any = None      ,  UpperCamelCase_      :    Optional[Any] = None      ,  UpperCamelCase_      :    List[str] = None      ,  UpperCamelCase_      :    Union[str, Any] = None      ,  UpperCamelCase_      :    Dict = None      ,  UpperCamelCase_      :    Optional[Any] = None      ,  UpperCamelCase_      :    Optional[Any] = None      ,  UpperCamelCase_      :    Union[str, Any] = ChannelDimension.FIRST      ,  ):


						"""simple docstring"""




						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_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	: Optional[int]		=					to_numpy_array(_A)

						if do_resize:
									__UpperCAmelCase	: List[str]		=					self.resize(image=_A      ,  size=_A      ,  resample=_A)

						if do_center_crop:
									__UpperCAmelCase	: Optional[int]		=					self.center_crop(_A      ,  size=_A)

						if do_rescale:
									__UpperCAmelCase	: Union[str, Any]		=					self.rescale(image=_A      ,  scale=_A)

						if do_normalize:
									__UpperCAmelCase	: int		=					self.normalize(image=_A      ,  mean=_A      ,  std=_A)

						__UpperCAmelCase	: Union[str, Any]		=					to_channel_dimension_format(_A      ,  _A)
						return image


			def       a_     (      self      :    Union[str, Any]      ,  UpperCamelCase_      :    int      ,  UpperCamelCase_      :    Optional[int] = None      ,  UpperCamelCase_      :    Optional[int] = None      ,  UpperCamelCase_      :    Optional[int] = None      ,  UpperCamelCase_      :    int = None      ,  UpperCamelCase_      :    Union[str, Any] = None      ,  UpperCamelCase_      :    Optional[int] = None      ,  UpperCamelCase_      :    Union[str, Any] = None      ,  UpperCamelCase_      :    str = None      ,  UpperCamelCase_      :    Any = None      ,  UpperCamelCase_      :    Tuple = None      ,  UpperCamelCase_      :    Tuple = None      ,  UpperCamelCase_      :    List[Any] = ChannelDimension.FIRST      ,  **UpperCamelCase_      :    Union[str, Any]      ,  ):


						"""simple docstring"""




						__UpperCAmelCase	: Optional[int]		=					do_resize if do_resize is not None else self.do_resize
						__UpperCAmelCase	: Any		=					resample if resample is not None else self.resample
						__UpperCAmelCase	: Tuple		=					do_center_crop if do_center_crop is not None else self.do_center_crop
						__UpperCAmelCase	: Union[str, Any]		=					do_rescale if do_rescale is not None else self.do_rescale
						__UpperCAmelCase	: List[str]		=					rescale_factor if rescale_factor is not None else self.rescale_factor
						__UpperCAmelCase	: int		=					do_normalize if do_normalize is not None else self.do_normalize
						__UpperCAmelCase	: Union[str, Any]		=					image_mean if image_mean is not None else self.image_mean
						__UpperCAmelCase	: List[Any]		=					image_std if image_std is not None else self.image_std

						__UpperCAmelCase	: str		=					size if size is not None else self.size
						__UpperCAmelCase	: str		=					get_size_dict(_A      ,  default_to_square=_A)
						__UpperCAmelCase	: Union[str, Any]		=					crop_size if crop_size is not None else self.crop_size
						__UpperCAmelCase	: List[str]		=					get_size_dict(_A      ,  param_name="crop_size")

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

						__UpperCAmelCase	: Dict		=					make_batched(_A)

						__UpperCAmelCase	: Dict		=					[
						    [
						        self._preprocess_image(
						            image=_A      ,  do_resize=_A      ,  size=_A      ,  resample=_A      ,  do_center_crop=_A      ,  crop_size=_A      ,  do_rescale=_A      ,  rescale_factor=_A      ,  do_normalize=_A      ,  image_mean=_A      ,  image_std=_A      ,  data_format=_A      ,  )
						        for img in video
						    ]
						    for video in videos
						]

						__UpperCAmelCase	: List[str]		=					{"pixel_values": videos}
						return BatchFeature(data=_A      ,  tensor_type=_A)








"""simple docstring"""





from ...configuration_utils import PretrainedConfig
from ...utils import logging


A   =       logging.get_logger(__name__)

A   =       {
    """bigcode/gpt_bigcode-santacoder""": """https://huggingface.co/bigcode/gpt_bigcode-santacoder/resolve/main/config.json""",
}



class      a__				(	__magic_name__   ):
			lowercase_    =	"gpt_bigcode"
			lowercase_    =	["past_key_values"]
			lowercase_    =	{
			    "hidden_size": "n_embd",
			    "max_position_embeddings": "n_positions",
			    "num_attention_heads": "n_head",
			    "num_hidden_layers": "n_layer",
			}


			def __init__(      self      :    Any      ,  UpperCamelCase_      :    Tuple=50257      ,  UpperCamelCase_      :    Dict=1024      ,  UpperCamelCase_      :    Optional[Any]=768      ,  UpperCamelCase_      :    Optional[Any]=12      ,  UpperCamelCase_      :    Any=12      ,  UpperCamelCase_      :    Optional[int]=None      ,  UpperCamelCase_      :    List[Any]="gelu_pytorch_tanh"      ,  UpperCamelCase_      :    Optional[Any]=0.1      ,  UpperCamelCase_      :    Union[str, Any]=0.1      ,  UpperCamelCase_      :    Tuple=0.1      ,  UpperCamelCase_      :    Tuple=1e-5      ,  UpperCamelCase_      :    List[str]=0.02      ,  UpperCamelCase_      :    Dict=True      ,  UpperCamelCase_      :    Optional[int]=True      ,  UpperCamelCase_      :    str=50256      ,  UpperCamelCase_      :    Union[str, Any]=50256      ,  UpperCamelCase_      :    Dict=True      ,  UpperCamelCase_      :    List[str]=True      ,  UpperCamelCase_      :    Union[str, Any]=True      ,  **UpperCamelCase_      :    Union[str, Any]      ,  ):


						"""simple docstring"""




						__UpperCAmelCase	: Tuple		=					vocab_size
						__UpperCAmelCase	: Optional[int]		=					n_positions
						__UpperCAmelCase	: Tuple		=					n_embd
						__UpperCAmelCase	: str		=					n_layer
						__UpperCAmelCase	: Dict		=					n_head
						__UpperCAmelCase	: Optional[Any]		=					n_inner
						__UpperCAmelCase	: Optional[Any]		=					activation_function
						__UpperCAmelCase	: List[str]		=					resid_pdrop
						__UpperCAmelCase	: List[Any]		=					embd_pdrop
						__UpperCAmelCase	: Optional[Any]		=					attn_pdrop
						__UpperCAmelCase	: Dict		=					layer_norm_epsilon
						__UpperCAmelCase	: List[str]		=					initializer_range
						__UpperCAmelCase	: int		=					scale_attn_weights
						__UpperCAmelCase	: Tuple		=					use_cache
						__UpperCAmelCase	: List[Any]		=					attention_softmax_in_fpaa
						__UpperCAmelCase	: Any		=					scale_attention_softmax_in_fpaa
						__UpperCAmelCase	: str		=					multi_query

						__UpperCAmelCase	: int		=					bos_token_id
						__UpperCAmelCase	: str		=					eos_token_id

						super().__init__(bos_token_id=UpperCamelCase_      ,  eos_token_id=UpperCamelCase_      ,  **UpperCamelCase_)


