






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


a_		:						Optional[Any]             =    logging.get_logger(__name__)

a_		:						str             =    {
    'tiiuae/falcon-40b': 'https://huggingface.co/tiiuae/falcon-40b/resolve/main/config.json',
    'tiiuae/falcon-7b': 'https://huggingface.co/tiiuae/falcon-7b/resolve/main/config.json',
}

class 		_snake_case  (  A__					):
			_lowercase		:    Union[str, Any]			     =							'''falcon'''
			_lowercase		:    int			     =							['''past_key_values''']






			def __init__(       self		,					a=6_5024		,					a=4544		,					a=32		,					a=71		,					a=1E-5		,					a=0.02		,					a=True		,					a=0.0		,					a=0.0		,					a=None		,					a=False		,					a=False		,					a=True		,					a=True		,					a=False		,					a=11		,					a=11		,					**a		,					)      ->       List[str]:
						SCREAMING_SNAKE_CASE						= vocab_size
						# Backward compatibility with n_embed kwarg
						SCREAMING_SNAKE_CASE						= kwargs.pop('n_embed'		,					a)
						SCREAMING_SNAKE_CASE						= hidden_size if n_embed is None else n_embed
						SCREAMING_SNAKE_CASE						= num_hidden_layers
						SCREAMING_SNAKE_CASE						= num_attention_heads
						SCREAMING_SNAKE_CASE						= layer_norm_epsilon
						SCREAMING_SNAKE_CASE						= initializer_range
						SCREAMING_SNAKE_CASE						= use_cache
						SCREAMING_SNAKE_CASE						= hidden_dropout
						SCREAMING_SNAKE_CASE						= attention_dropout

						SCREAMING_SNAKE_CASE						= bos_token_id
						SCREAMING_SNAKE_CASE						= eos_token_id
						SCREAMING_SNAKE_CASE						= num_attention_heads if num_kv_heads is None else num_kv_heads
						SCREAMING_SNAKE_CASE						= alibi
						SCREAMING_SNAKE_CASE						= new_decoder_architecture
						SCREAMING_SNAKE_CASE						= multi_query  # Ignored when new_decoder_architecture is True
						SCREAMING_SNAKE_CASE						= parallel_attn
						SCREAMING_SNAKE_CASE						= bias

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






			@property
			def    SCREAMING_SNAKE_CASE__    (       self)      ->       Union[str, Any]:
						return self.hidden_size // self.num_attention_heads







			@property
			def    SCREAMING_SNAKE_CASE__    (       self)      ->       Union[str, Any]:
						return not self.alibi












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 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_vision_available, logging


if is_vision_available():
				import PIL


a_		:						Optional[int]             =    logging.get_logger(__name__)






def 				lowerCamelCase__				(_UpperCAmelCase							,       _UpperCAmelCase):
			SCREAMING_SNAKE_CASE						= b.T
			SCREAMING_SNAKE_CASE						= np.sum(np.square(_UpperCAmelCase)							,       axis=1)
			SCREAMING_SNAKE_CASE						= np.sum(np.square(_UpperCAmelCase)							,       axis=0)
			SCREAMING_SNAKE_CASE						= np.matmul(_UpperCAmelCase							,       _UpperCAmelCase)
			SCREAMING_SNAKE_CASE						= aa[:, None] - 2 * ab + ba[None, :]
			return d






def 				lowerCamelCase__				(_UpperCAmelCase							,       _UpperCAmelCase):
			SCREAMING_SNAKE_CASE						= x.reshape(-1							,       3)
			SCREAMING_SNAKE_CASE						= squared_euclidean_distance(_UpperCAmelCase							,       _UpperCAmelCase)
			return np.argmin(_UpperCAmelCase							,       axis=1)







class 		_snake_case  (  A__					):
			_lowercase		:    str			     =							['''pixel_values''']






			def __init__(       self		,					a = None		,					a = True		,					a = None		,					a = PILImageResampling.BILINEAR		,					a = True		,					a = True		,					**a		,					)      ->       None:
						super().__init__(**a)
						SCREAMING_SNAKE_CASE						= size if size is not None else {'height': 256, 'width': 256}
						SCREAMING_SNAKE_CASE						= get_size_dict(a)
						SCREAMING_SNAKE_CASE						= np.array(a) if clusters is not None else None
						SCREAMING_SNAKE_CASE						= do_resize
						SCREAMING_SNAKE_CASE						= size
						SCREAMING_SNAKE_CASE						= resample
						SCREAMING_SNAKE_CASE						= do_normalize
						SCREAMING_SNAKE_CASE						= do_color_quantize






			def    SCREAMING_SNAKE_CASE__    (       self		,					a		,					a		,					a = PILImageResampling.BILINEAR		,					a = None		,					**a		,					)      ->       np.ndarray:
						SCREAMING_SNAKE_CASE						= get_size_dict(a)
						if "height" not in size or "width" not in size:
									raise ValueError(f'''Size dictionary must contain both height and width keys. Got {size.keys()}''')
						return resize(
						    a		,					size=(size['height'], size['width'])		,					resample=a		,					data_format=a		,					**a)






			def    SCREAMING_SNAKE_CASE__    (       self		,					a		,					a = None		,					)      ->       np.ndarray:
						SCREAMING_SNAKE_CASE						= rescale(image=a		,					scale=1 / 1_27.5		,					data_format=a)
						SCREAMING_SNAKE_CASE						= image - 1
						return image







			def    SCREAMING_SNAKE_CASE__    (       self		,					a		,					a = None		,					a = None		,					a = None		,					a = None		,					a = None		,					a = None		,					a = None		,					a = ChannelDimension.FIRST		,					**a		,					)      ->       PIL.Image.Image:
						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(a)
						SCREAMING_SNAKE_CASE						= resample if resample is not None else self.resample
						SCREAMING_SNAKE_CASE						= do_normalize if do_normalize is not None else self.do_normalize
						SCREAMING_SNAKE_CASE						= do_color_quantize if do_color_quantize is not None else self.do_color_quantize
						SCREAMING_SNAKE_CASE						= clusters if clusters is not None else self.clusters
						SCREAMING_SNAKE_CASE						= np.array(a)

						SCREAMING_SNAKE_CASE						= make_list_of_images(a)

						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.')

						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_color_quantize and clusters is None:
									raise ValueError('Clusters must be specified if do_color_quantize is True.')

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

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

						if do_normalize:
									SCREAMING_SNAKE_CASE						= [self.normalize(image=a) for image in images]

						if do_color_quantize:
									SCREAMING_SNAKE_CASE						= [to_channel_dimension_format(a		,					ChannelDimension.LAST) for image in images]
									# color quantize from (batch_size, height, width, 3) to (batch_size, height, width)
									SCREAMING_SNAKE_CASE						= np.array(a)
									SCREAMING_SNAKE_CASE						= color_quantize(a		,					a).reshape(images.shape[:-1])

									# flatten to (batch_size, height*width)
									SCREAMING_SNAKE_CASE						= images.shape[0]
									SCREAMING_SNAKE_CASE						= images.reshape(a		,					-1)

									# We need to convert back to a list of images to keep consistent behaviour across processors.
									SCREAMING_SNAKE_CASE						= list(a)
						else:
									SCREAMING_SNAKE_CASE						= [to_channel_dimension_format(a		,					a) for image in images]

						SCREAMING_SNAKE_CASE						= {'input_ids': images}
						return BatchFeature(data=a		,					tensor_type=a)




