





'''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,
    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


snake_case_  :							Any            =	logging.get_logger(__name__)


if is_vision_available():
					import PIL


class        __a   (lowerCamelCase  ):
							__a       : Any          =							["pixel_values"]

							def __init__(				self				:  Optional[int]							,  __magic_name__				:  bool = True							,  __magic_name__				:  Dict[str, int] = None							,  __magic_name__				:  PILImageResampling = PILImageResampling.BICUBIC							,  __magic_name__				:  bool = True							,  __magic_name__				:  Dict[str, int] = None							,  __magic_name__				:  bool = True							,  __magic_name__				:  Union[int, float] = 1 / 2_55							,  __magic_name__				:  bool = True							,  __magic_name__				:  Optional[Union[float, List[float]]] = None							,  __magic_name__				:  Optional[Union[float, List[float]]] = None							,  __magic_name__				:  bool = True							,  **__magic_name__				:  Union[str, Any]							,  )       ->							None:







													"""simple docstring"""
													super().__init__(**__magic_name__ )
													UpperCAmelCase_      :   List[Any]      =	size if size is not None else {'''shortest_edge''': 2_24}
													UpperCAmelCase_      :   List[str]      =	get_size_dict(__magic_name__							,  default_to_square=__magic_name__ )
													UpperCAmelCase_      :   int      =	crop_size if crop_size is not None else {'''height''': 2_24, '''width''': 2_24}
													UpperCAmelCase_      :   Union[str, Any]      =	get_size_dict(__magic_name__ )

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

							def      UpperCAmelCase__						(				self				:  int							,  __magic_name__				:  np.ndarray							,  __magic_name__				:  Dict[str, int]							,  __magic_name__				:  PILImageResampling = PILImageResampling.BICUBIC							,  __magic_name__				:  Optional[Union[str, ChannelDimension]] = None							,  **__magic_name__				:  Optional[int]							,  )       ->							np.ndarray:







													"""simple docstring"""
													UpperCAmelCase_      :   Optional[Any]      =	get_size_dict(__magic_name__							,  default_to_square=__magic_name__ )
													UpperCAmelCase_      :   Any      =	get_resize_output_image_size(
													    __magic_name__							,  size=(size['''height'''], size['''width'''])							,  default_to_square=__magic_name__ )
													return resize(__magic_name__							,  size=__magic_name__							,  resample=__magic_name__							,  data_format=__magic_name__							,  **__magic_name__ )

							def      UpperCAmelCase__						(				self				:  List[Any]							,  __magic_name__				:  np.ndarray							,  __magic_name__				:  Dict[str, int]							,  __magic_name__				:  Optional[Union[str, ChannelDimension]] = None							,  **__magic_name__				:  Any							,  )       ->							np.ndarray:







													"""simple docstring"""
													UpperCAmelCase_      :   List[Any]      =	get_size_dict(__magic_name__ )
													return center_crop(__magic_name__							,  size=(size['''height'''], size['''width'''])							,  data_format=__magic_name__							,  **__magic_name__ )

							def      UpperCAmelCase__						(				self				:  str							,  __magic_name__				:  np.ndarray							,  __magic_name__				:  Union[int, float]							,  __magic_name__				:  Optional[Union[str, ChannelDimension]] = None							,  **__magic_name__				:  Any							,  )       ->							Union[str, Any]:







													"""simple docstring"""
													return rescale(__magic_name__							,  scale=__magic_name__							,  data_format=__magic_name__							,  **__magic_name__ )

							def      UpperCAmelCase__						(				self				:  str							,  __magic_name__				:  np.ndarray							,  __magic_name__				:  Union[float, List[float]]							,  __magic_name__				:  Union[float, List[float]]							,  __magic_name__				:  Optional[Union[str, ChannelDimension]] = None							,  **__magic_name__				:  Optional[int]							,  )       ->							np.ndarray:







													"""simple docstring"""
													return normalize(__magic_name__							,  mean=__magic_name__							,  std=__magic_name__							,  data_format=__magic_name__							,  **__magic_name__ )



							def      UpperCAmelCase__						(				self				:  Dict							,  __magic_name__				:  ImageInput							,  __magic_name__				:  bool = None							,  __magic_name__				:  Dict[str, int] = None							,  __magic_name__				:  PILImageResampling = None							,  __magic_name__				:  bool = None							,  __magic_name__				:  int = None							,  __magic_name__				:  bool = None							,  __magic_name__				:  float = None							,  __magic_name__				:  bool = None							,  __magic_name__				:  Optional[Union[float, List[float]]] = None							,  __magic_name__				:  Optional[Union[float, List[float]]] = None							,  __magic_name__				:  bool = None							,  __magic_name__				:  Optional[Union[str, TensorType]] = None							,  __magic_name__				:  Optional[ChannelDimension] = ChannelDimension.FIRST							,  **__magic_name__				:  Union[str, Any]							,  )       ->							PIL.Image.Image:







													"""simple docstring"""
													UpperCAmelCase_      :   int      =	do_resize if do_resize is not None else self.do_resize
													UpperCAmelCase_      :   Dict      =	size if size is not None else self.size
													UpperCAmelCase_      :   Union[str, Any]      =	get_size_dict(__magic_name__							,  default_to_square=__magic_name__ )
													UpperCAmelCase_      :   str      =	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_      :   List[str]      =	crop_size if crop_size is not None else self.crop_size
													UpperCAmelCase_      :   Optional[Any]      =	get_size_dict(__magic_name__ )
													UpperCAmelCase_      :   str      =	do_rescale if do_rescale is not None else self.do_rescale
													UpperCAmelCase_      :   Tuple      =	rescale_factor if rescale_factor is not None else self.rescale_factor
													UpperCAmelCase_      :   List[Any]      =	do_normalize if do_normalize is not None else self.do_normalize
													UpperCAmelCase_      :   Tuple      =	image_mean if image_mean is not None else self.image_mean
													UpperCAmelCase_      :   int      =	image_std if image_std is not None else self.image_std
													UpperCAmelCase_      :   Optional[Any]      =	do_convert_rgb if do_convert_rgb is not None else self.do_convert_rgb

													UpperCAmelCase_      :   Any      =	make_list_of_images(__magic_name__ )

													if not valid_images(__magic_name__ ):
																			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:
																			UpperCAmelCase_      :   Optional[int]      =	[convert_to_rgb(__magic_name__ ) for image in images]

													# All transformations expect numpy arrays.
													UpperCAmelCase_      :   Optional[Any]      =	[to_numpy_array(__magic_name__ ) for image in images]

													if do_resize:
																			UpperCAmelCase_      :   Dict      =	[self.resize(image=__magic_name__							,  size=__magic_name__							,  resample=__magic_name__ ) for image in images]

													if do_center_crop:
																			UpperCAmelCase_      :   Union[str, Any]      =	[self.center_crop(image=__magic_name__							,  size=__magic_name__ ) for image in images]

													if do_rescale:
																			UpperCAmelCase_      :   Dict      =	[self.rescale(image=__magic_name__							,  scale=__magic_name__ ) for image in images]

													if do_normalize:
																			UpperCAmelCase_      :   Optional[int]      =	[self.normalize(image=__magic_name__							,  mean=__magic_name__							,  std=__magic_name__ ) for image in images]

													UpperCAmelCase_      :   Optional[Any]      =	[to_channel_dimension_format(__magic_name__							,  __magic_name__ ) for image in images]

													UpperCAmelCase_      :   int      =	{'''pixel_values''': images}
													return BatchFeature(data=__magic_name__							,  tensor_type=__magic_name__ )






'''simple docstring'''





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


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

UpperCamelCase       :     Union[str, Any]			=    {
    """ZinengTang/tvlt-base""": """https://huggingface.co/ZinengTang/tvlt-base/blob/main/config.json""",
}



class   UpperCamelCase					(       a_       ):







    """simple docstring"""





    A     :    int				=			"tvlt"





    def __init__(					self     :						List[str]							,							UpperCAmelCase_     :						Any=2_2_4							,							UpperCAmelCase_     :						Optional[Any]=2_0_4_8							,							UpperCAmelCase_     :						Dict=1_2_8							,							UpperCAmelCase_     :						str=[1_6, 1_6]							,							UpperCAmelCase_     :						int=[1_6, 1_6]							,							UpperCAmelCase_     :						int=3							,							UpperCAmelCase_     :						Optional[int]=1							,							UpperCAmelCase_     :						List[str]=8							,							UpperCAmelCase_     :						List[Any]=7_6_8							,							UpperCAmelCase_     :						int=1_2							,							UpperCAmelCase_     :						List[Any]=1_2							,							UpperCAmelCase_     :						Optional[Any]=3_0_7_2							,							UpperCAmelCase_     :						List[str]="gelu"							,							UpperCAmelCase_     :						Tuple=0.0							,							UpperCAmelCase_     :						Optional[Any]=0.0							,							UpperCAmelCase_     :						Tuple=0.02							,							UpperCAmelCase_     :						Any=1e-6							,							UpperCAmelCase_     :						Dict=True							,							UpperCAmelCase_     :						Union[str, Any]=False							,							UpperCAmelCase_     :						Tuple=1_6							,							UpperCAmelCase_     :						str=5_1_2							,							UpperCAmelCase_     :						List[str]=8							,							UpperCAmelCase_     :						Union[str, Any]=2_0_4_8							,							UpperCAmelCase_     :						Tuple=0.75							,							UpperCAmelCase_     :						Optional[Any]=0.15							,							UpperCAmelCase_     :						Union[str, Any]="frame-level"							,							UpperCAmelCase_     :						List[str]=True							,							UpperCAmelCase_     :						Any=True							,							UpperCAmelCase_     :						Optional[int]="classification"							,							**UpperCAmelCase_     :						Any							,							):


         """simple docstring"""







         super().__init__(**UpperCAmelCase_)

         if audio_mask_type not in ("frame-level", "patch_level"):
              raise ValueError(
                  'audio_mask_type must be one of two acceptable strategies - {\'frame_level\', \'patch-level\') '
                  f"""got {audio_mask_type}""")

         a					:							str							= image_size
         a					:							List[Any]							= spectrogram_length
         a					:							Union[str, Any]							= frequency_length
         a					:							str							= image_patch_size
         a					:							Dict							= audio_patch_size
         a					:							Dict							= num_image_channels
         a					:							Tuple							= num_audio_channels
         a					:							Optional[int]							= num_frames

         a					:							str							= hidden_size
         a					:							List[Any]							= num_hidden_layers
         a					:							Optional[Any]							= num_attention_heads
         a					:							Any							= intermediate_size
         a					:							List[Any]							= hidden_act
         a					:							int							= hidden_dropout_prob
         a					:							Optional[Any]							= attention_probs_dropout_prob
         a					:							Optional[Any]							= initializer_range
         a					:							List[str]							= layer_norm_eps
         a					:							List[Any]							= qkv_bias
         a					:							Dict							= use_mean_pooling

         a					:							List[Any]							= decoder_num_attention_heads
         a					:							Any							= decoder_hidden_size
         a					:							int							= decoder_num_hidden_layers
         a					:							Tuple							= decoder_intermediate_size
         a					:							Tuple							= pixel_mask_ratio
         a					:							List[Any]							= audio_mask_ratio
         a					:							Optional[Any]							= audio_mask_type

         a					:							Any							= task_matching
         a					:							Optional[Any]							= task_mae
         a					:							List[str]							= loss_type

