



import warnings

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding


class 	a__       (       _snake_case       ):


					"""simple docstring"""



					A__  :				Any					 =				['''image_processor''', '''tokenizer''']
					A__  :				int					 =				'''VideoMAEImageProcessor'''
					A__  :				Optional[Any]					 =				('''CLIPTokenizer''', '''CLIPTokenizerFast''')

					def __init__(		self     :Dict      ,  lowercase__     :Optional[int]=None      ,  lowercase__     :Optional[Any]=None      ,  **lowercase__     :Tuple    ):
										lowercase						   =       None
										if "feature_extractor" in kwargs:
															warnings.warn(
															    'The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`'
															    ' instead.'      ,  lowercase__      ,  )
															lowercase						   =       kwargs.pop('feature_extractor'    )

										lowercase						   =       image_processor if image_processor is not None else feature_extractor
										if image_processor is None:
															raise ValueError('You need to specify an `image_processor`.'    )
										if tokenizer is None:
															raise ValueError('You need to specify a `tokenizer`.'    )

										super().__init__(lowercase__      ,  lowercase__    )
										lowercase						   =       self.image_processor

					def __call__(		self     :Any      ,  lowercase__     :Tuple=None      ,  lowercase__     :Union[str, Any]=None      ,  lowercase__     :Tuple=None      ,  **lowercase__     :Any    ):

										if text is None and videos is None:
															raise ValueError('You have to specify either text or videos. Both cannot be none.'    )

										if text is not None:
															lowercase						   =       self.tokenizer(lowercase__      ,  return_tensors=lowercase__      ,  **lowercase__    )

										if videos is not None:
															lowercase						   =       self.image_processor(lowercase__      ,  return_tensors=lowercase__      ,  **lowercase__    )

										if text is not None and videos is not None:
															lowercase						   =       image_features.pixel_values
															return encoding
										elif text is not None:
															return encoding
										else:
															return BatchEncoding(data=dict(**lowercase__    )      ,  tensor_type=lowercase__    )

					def 				__UpperCAmelCase		(		self     :Tuple      ,  *lowercase__     :Optional[int]      ,  **lowercase__     :Optional[int]    ):
										return self.tokenizer.batch_decode(*lowercase__      ,  **lowercase__    )

					def 				__UpperCAmelCase		(		self     :List[Any]      ,  *lowercase__     :str      ,  **lowercase__     :Any    ):
										return self.tokenizer.decode(*lowercase__      ,  **lowercase__    )

					@property
					def 				__UpperCAmelCase		(		self     :Any    ):
										return ["input_ids", "attention_mask", "position_ids", "pixel_values"]

					@property
					def 				__UpperCAmelCase		(		self     :Union[str, Any]    ):
										warnings.warn(
										    '`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead.'      ,  lowercase__      ,  )
										return self.image_processor_class



					@property
					def 				__UpperCAmelCase		(		self     :List[Any]    ):
										warnings.warn(
										    '`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead.'      ,  lowercase__      ,  )
										return self.image_processor











from typing import List, Optional, Tuple, Union

from . import logging
from .import_utils import is_torch_available, is_torch_version


if is_torch_available():
		import torch

__magic_name__       =     logging.get_logger(__name__)  # pylint: disable=invalid-name

try:
		from torch._dynamo import allow_in_graph as maybe_allow_in_graph
except (ImportError, ModuleNotFoundError):





		def 		__snake_case						(    cls				):
							"""simple docstring"""






							return cls





def 		__snake_case						(    _UpperCAmelCase       ,			_UpperCAmelCase = None       ,			_UpperCAmelCase = None       ,			_UpperCAmelCase = None       ,			_UpperCAmelCase = None       ,			):
					"""simple docstring"""






					lowercase						   =       device
					lowercase						   =       shape[0]

					lowercase						   =       layout or torch.strided
					lowercase						   =       device or torch.device('cpu'				)

					if generator is not None:
										lowercase						   =       generator.device.type if not isinstance(_UpperCAmelCase       ,			_UpperCAmelCase				) else generator[0].device.type
										if gen_device_type != device.type and gen_device_type == "cpu":
															lowercase						   =       'cpu'
															if device != "mps":
																				logger.info(
																				    f"""The passed generator was created on 'cpu' even though a tensor on {device} was expected."""
																				    f""" Tensors will be created on 'cpu' and then moved to {device}. Note that one can probably"""
																				    f""" slighly speed up this function by passing a generator that was created on the {device} device."""				)
										elif gen_device_type != device.type and gen_device_type == "cuda":
															raise ValueError(f"""Cannot generate a {device} tensor from a generator of type {gen_device_type}."""				)

					if isinstance(_UpperCAmelCase       ,			_UpperCAmelCase				):
										lowercase						   =       (1,) + shape[1:]
										lowercase						   =       [
										    torch.randn(_UpperCAmelCase       ,			generator=generator[i]       ,			device=_UpperCAmelCase       ,			dtype=_UpperCAmelCase       ,			layout=_UpperCAmelCase				)
										    for i in range(_UpperCAmelCase				)
										]
										lowercase						   =       torch.cat(_UpperCAmelCase       ,			dim=0				).to(_UpperCAmelCase				)
					else:
										lowercase						   =       torch.randn(_UpperCAmelCase       ,			generator=_UpperCAmelCase       ,			device=_UpperCAmelCase       ,			dtype=_UpperCAmelCase       ,			layout=_UpperCAmelCase				).to(_UpperCAmelCase				)

					return latents





def 		__snake_case						(    _UpperCAmelCase				):
					"""simple docstring"""






					if is_torch_version('<'       ,			'2.0.0'				) or not hasattr(_UpperCAmelCase       ,			'_dynamo'				):
										return False
					return isinstance(_UpperCAmelCase       ,			torch._dynamo.eval_frame.OptimizedModule				)






