



"""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


SCREAMING_SNAKE_CASE_				= logging.get_logger(__name__)




class 			snake_case_						(						a_				):
							__lowerCAmelCase    					=					["pixel_values"]






							def __init__(   self			,     a_ = True			,     a_ = None			,     a_ = PILImageResampling.BICUBIC			,     a_ = True			,     a_ = 1 / 2_5_5			,     a_ = True			,     a_ = None			,     a_ = None			,     a_ = True			,     **a_			,     ):
									super().__init__(**a_      )
									a_     :      Optional[Any] 						=     size if size is not None else {"height": 3_8_4, "width": 3_8_4}
									a_     :      Tuple 						=     get_size_dict(a_			,     default_to_square=a_      )

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






							def snake_case_  (   self			,     a_			,     a_			,     a_ = PILImageResampling.BICUBIC			,     a_ = None			,     **a_			,     ):
									a_     :      Union[str, Any] 						=     get_size_dict(a_			,     default_to_square=a_      )
									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()}"""      )
									a_     :      Tuple 						=     (size["height"], size["width"])
									return resize(a_			,     size=a_			,     resample=a_			,     data_format=a_			,     **a_      )






							def snake_case_  (   self			,     a_			,     a_			,     a_ = None			,     **a_			,     ):
									return rescale(a_			,     scale=a_			,     data_format=a_			,     **a_      )






							def snake_case_  (   self			,     a_			,     a_			,     a_			,     a_ = None			,     **a_			,     ):
									return normalize(a_			,     mean=a_			,     std=a_			,     data_format=a_			,     **a_      )






							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_			,     ):
									a_     :      Optional[Any] 						=     do_resize if do_resize is not None else self.do_resize
									a_     :      List[str] 						=     resample if resample is not None else self.resample
									a_     :      str 						=     do_rescale if do_rescale is not None else self.do_rescale
									a_     :      int 						=     rescale_factor if rescale_factor is not None else self.rescale_factor
									a_     :      List[Any] 						=     do_normalize if do_normalize is not None else self.do_normalize
									a_     :      Optional[int] 						=     image_mean if image_mean is not None else self.image_mean
									a_     :      int 						=     image_std if image_std is not None else self.image_std
									a_     :      List[Any] 						=     do_convert_rgb if do_convert_rgb is not None else self.do_convert_rgb

									a_     :      Dict 						=     size if size is not None else self.size
									a_     :      Optional[int] 						=     get_size_dict(a_			,     default_to_square=a_      )

									a_     :      List[Any] 						=     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_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:
											a_     :      Optional[int] 						=     [convert_to_rgb(a_      ) for image in images]

									# All transformations expect numpy arrays.
									a_     :      int 						=     [to_numpy_array(a_      ) for image in images]

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

									if do_rescale:
											a_     :      Optional[Any] 						=     [self.rescale(image=a_			,     scale=a_      ) for image in images]

									if do_normalize:
											a_     :      str 						=     [self.normalize(image=a_			,     mean=a_			,     std=a_      ) for image in images]

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

									a_     :      Dict 						=     BatchFeature(data={"pixel_values": images}			,     tensor_type=a_      )

									return encoded_outputs




"""simple docstring"""
from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_sentencepiece_available,
    is_tokenizers_available,
    is_torch_available,
)


SCREAMING_SNAKE_CASE_				= {
    """configuration_llama""": ["""LLAMA_PRETRAINED_CONFIG_ARCHIVE_MAP""", """LlamaConfig"""],
}

try:
					if not is_sentencepiece_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					SCREAMING_SNAKE_CASE_				= ["""LlamaTokenizer"""]

try:
					if not is_tokenizers_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					SCREAMING_SNAKE_CASE_				= ["""LlamaTokenizerFast"""]

try:
					if not is_torch_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					SCREAMING_SNAKE_CASE_				= [
					    """LlamaForCausalLM""",
					    """LlamaModel""",
					    """LlamaPreTrainedModel""",
					    """LlamaForSequenceClassification""",
					]


if TYPE_CHECKING:
					from .configuration_llama import LLAMA_PRETRAINED_CONFIG_ARCHIVE_MAP, LlamaConfig

					try:
										if not is_sentencepiece_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .tokenization_llama import LlamaTokenizer

					try:
										if not is_tokenizers_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .tokenization_llama_fast import LlamaTokenizerFast

					try:
										if not is_torch_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_llama import LlamaForCausalLM, LlamaForSequenceClassification, LlamaModel, LlamaPreTrainedModel


else:
					import sys

					SCREAMING_SNAKE_CASE_				= _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)