






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


__a   :							int						= logging.get_logger(__name__)


if is_vision_available():
  import PIL


class    __lowercase   (						A__	):







     '''simple docstring'''
     SCREAMING_SNAKE_CASE     =					["pixel_values"]




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


         """simple docstring"""



         super().__init__(**a__					)
         __A       =						size if size is not None else {"""shortest_edge""": 224}
         __A       =						get_size_dict(a__			,						default_to_square=a__					)
         __A       =						crop_size if crop_size is not None else {"""height""": 224, """width""": 224}
         __A       =						get_size_dict(a__			,						default_to_square=a__			,						param_name="""crop_size"""					)

         __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 if image_mean is not None else OPENAI_CLIP_MEAN
         __A       =						image_std if image_std is not None else OPENAI_CLIP_STD
         __A       =						do_convert_rgb




     def 		lowerCAmelCase_  (					self							:      Optional[int]			,						UpperCamelCase_							:      List[Any]			,						UpperCamelCase_							:      Any			,						UpperCamelCase_							:      Tuple = PILImageResampling.BICUBIC			,						UpperCamelCase_							:      List[Any] = None			,						**UpperCamelCase_							:      Optional[Any]			,						):


         """simple docstring"""



         __A       =						get_size_dict(a__			,						default_to_square=a__					)
         if "shortest_edge" not in size:
             raise ValueError(F"The `size` parameter must contain the key `shortest_edge`. Got {size.keys()}"					)
         __A       =						get_resize_output_image_size(a__			,						size=size["""shortest_edge"""]			,						default_to_square=a__					)
         return resize(a__			,						size=a__			,						resample=a__			,						data_format=a__			,						**a__					)




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


         """simple docstring"""



         __A       =						get_size_dict(a__					)
         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(a__			,						size=(size["""height"""], size["""width"""])			,						data_format=a__			,						**a__					)




     def 		lowerCAmelCase_  (					self							:      str			,						UpperCamelCase_							:      Dict			,						UpperCamelCase_							:      Dict			,						UpperCamelCase_							:      int = None			,						**UpperCamelCase_							:      List[str]			,						):


         """simple docstring"""



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




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


         """simple docstring"""



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





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


         """simple docstring"""



         __A       =						do_resize if do_resize is not None else self.do_resize
         __A       =						size if size is not None else self.size
         __A       =						get_size_dict(a__			,						param_name="""size"""			,						default_to_square=a__					)
         __A       =						resample if resample is not None else self.resample
         __A       =						do_center_crop if do_center_crop is not None else self.do_center_crop
         __A       =						crop_size if crop_size is not None else self.crop_size
         __A       =						get_size_dict(a__			,						param_name="""crop_size"""			,						default_to_square=a__					)
         __A       =						do_rescale if do_rescale is not None else self.do_rescale
         __A       =						rescale_factor if rescale_factor is not None else self.rescale_factor
         __A       =						do_normalize if do_normalize is not None else self.do_normalize
         __A       =						image_mean if image_mean is not None else self.image_mean
         __A       =						image_std if image_std is not None else self.image_std
         __A       =						do_convert_rgb if do_convert_rgb is not None else self.do_convert_rgb

         __A       =						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:
             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:
             __A       =						[convert_to_rgb(a__					) for image in images]

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

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

         if do_center_crop:
             __A       =						[self.center_crop(image=a__			,						size=a__					) for image in images]

         if do_rescale:
             __A       =						[self.rescale(image=a__			,						scale=a__					) for image in images]

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

         __A       =						[to_channel_dimension_format(a__			,						a__					) for image in images]

         __A       =						{"""pixel_values""": images}
         return BatchFeature(data=a__			,						tensor_type=a__					)









from typing import TYPE_CHECKING

from ....utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


_lowercase    	=		{
    "configuration_mctct": ["MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP", "MCTCTConfig"],
    "feature_extraction_mctct": ["MCTCTFeatureExtractor"],
    "processing_mctct": ["MCTCTProcessor"],
}


try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   _lowercase    	=		[
       "MCTCT_PRETRAINED_MODEL_ARCHIVE_LIST",
       "MCTCTForCTC",
       "MCTCTModel",
       "MCTCTPreTrainedModel",
   ]


if TYPE_CHECKING:
   from .configuration_mctct import MCTCT_PRETRAINED_CONFIG_ARCHIVE_MAP, MCTCTConfig
   from .feature_extraction_mctct import MCTCTFeatureExtractor
   from .processing_mctct import MCTCTProcessor

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_mctct import MCTCT_PRETRAINED_MODEL_ARCHIVE_LIST, MCTCTForCTC, MCTCTModel, MCTCTPreTrainedModel

else:
   import sys

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