





"""simple docstring"""




# Copyright 2023 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


UpperCamelCase_									={
    """configuration_mgp_str""": ["""MGP_STR_PRETRAINED_CONFIG_ARCHIVE_MAP""", """MgpstrConfig"""],
    """processing_mgp_str""": ["""MgpstrProcessor"""],
    """tokenization_mgp_str""": ["""MgpstrTokenizer"""],
}

try:
						if not is_torch_available():
												raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
						pass
else:
						UpperCamelCase_									=[
						    """MGP_STR_PRETRAINED_MODEL_ARCHIVE_LIST""",
						    """MgpstrModel""",
						    """MgpstrPreTrainedModel""",
						    """MgpstrForSceneTextRecognition""",
						]

if TYPE_CHECKING:
						from .configuration_mgp_str import MGP_STR_PRETRAINED_CONFIG_ARCHIVE_MAP, MgpstrConfig
						from .processing_mgp_str import MgpstrProcessor
						from .tokenization_mgp_str import MgpstrTokenizer

						try:
												if not is_torch_available():
																		raise OptionalDependencyNotAvailable()
						except OptionalDependencyNotAvailable:
												pass
						else:
												from .modeling_mgp_str import (
												    MGP_STR_PRETRAINED_MODEL_ARCHIVE_LIST,
												    MgpstrForSceneTextRecognition,
												    MgpstrModel,
												    MgpstrPreTrainedModel,
												)
else:
						import sys

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










"""simple docstring"""




from ...processing_utils import ProcessorMixin




class 			_a						(				_lowerCAmelCase    ):
				UpperCamelCase								=   ['''image_processor''', '''feature_extractor''']
				UpperCamelCase								=   '''TvltImageProcessor'''
				UpperCamelCase								=   '''TvltFeatureExtractor'''






				def __init__(			self		:   Union[str, Any],			lowerCAmelCase__		:   str,			lowerCAmelCase__		:   List[str]							)     ->				Optional[Any]:




										'''simple docstring'''



										super().__init__(image_processor=lowerCAmelCase__,			feature_extractor=lowerCAmelCase__							)

										_UpperCamelCase      : List[str]         =   image_processor
										_UpperCamelCase      : int         =   feature_extractor






				def __call__(			self		:   List[str],			lowerCAmelCase__		:   Optional[int]=None,			lowerCAmelCase__		:   str=None,			lowerCAmelCase__		:   Dict=None,			lowerCAmelCase__		:   str=None,			lowerCAmelCase__		:   Optional[int]=False,			lowerCAmelCase__		:   str=False,			*lowerCAmelCase__		:   List[str],			**lowerCAmelCase__		:   Optional[int],			)     ->				Dict:




										'''simple docstring'''



										if images is None and audio is None:
																raise ValueError('''You need to specify either an `images` or `audio` input to process.'''							)

										_UpperCamelCase      : Optional[int]         =   None
										if images is not None:
																_UpperCamelCase      : Optional[int]         =   self.image_processor(lowerCAmelCase__,			mask_pixel=lowerCAmelCase__,			*lowerCAmelCase__,			**lowerCAmelCase__							)
										if images_mixed is not None:
																_UpperCamelCase      : str         =   self.image_processor(lowerCAmelCase__,			is_mixed=lowerCAmelCase__,			*lowerCAmelCase__,			**lowerCAmelCase__							)
										if audio is not None:
																_UpperCamelCase      : Union[str, Any]         =   self.feature_extractor(
																    lowerCAmelCase__,			*lowerCAmelCase__,			sampling_rate=lowerCAmelCase__,			mask_audio=lowerCAmelCase__,			**lowerCAmelCase__							)

										_UpperCamelCase      : str         =   {}
										if audio is not None:
																output_dict.update(lowerCAmelCase__							)
										if images is not None:
																output_dict.update(lowerCAmelCase__							)
										if images_mixed_dict is not None:
																output_dict.update(lowerCAmelCase__							)
										return output_dict






				@property
				def     snake_case     (			self		:   List[str]							)     ->				Tuple:




										'''simple docstring'''



										_UpperCamelCase      : List[str]         =   self.image_processor.model_input_names
										_UpperCamelCase      : List[Any]         =   self.feature_extractor.model_input_names
										return list(dict.fromkeys(image_processor_input_names + feature_extractor_input_names							)							)



