






# 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

# rely on isort to merge the imports
from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


lowercase  :							Tuple			  =    {
    '''configuration_efficientnet''': [
        '''EFFICIENTNET_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''EfficientNetConfig''',
        '''EfficientNetOnnxConfig''',
    ]
}

try:
							if not is_vision_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							lowercase  :							List[Any]			  =    ['''EfficientNetImageProcessor''']

try:
							if not is_torch_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							lowercase  :							Dict			  =    [
							    '''EFFICIENTNET_PRETRAINED_MODEL_ARCHIVE_LIST''',
							    '''EfficientNetForImageClassification''',
							    '''EfficientNetModel''',
							    '''EfficientNetPreTrainedModel''',
							]

if TYPE_CHECKING:
							from .configuration_efficientnet import (
							    EFFICIENTNET_PRETRAINED_CONFIG_ARCHIVE_MAP,
							    EfficientNetConfig,
							    EfficientNetOnnxConfig,
							)

							try:
														if not is_vision_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .image_processing_efficientnet import EfficientNetImageProcessor

							try:
														if not is_torch_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_efficientnet import (
														    EFFICIENTNET_PRETRAINED_MODEL_ARCHIVE_LIST,
														    EfficientNetForImageClassification,
														    EfficientNetModel,
														    EfficientNetPreTrainedModel,
														)

else:
							import sys

							lowercase  :							List[Any]			  =    _LazyModule(__name__, globals()['''__file__'''], _import_structure)








import warnings
from typing import List, Optional, Union

from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy
from ...utils import TensorType




class 		UpperCAmelCase_						(	SCREAMING_SNAKE_CASE__					):


						'''simple docstring'''




						A     :   Tuple						=					['image_processor', 'tokenizer']
						A     :   List[Any]						=					'ViltImageProcessor'
						A     :   Optional[Any]						=					('BertTokenizer', 'BertTokenizerFast')






						def __init__(	self		,				_SCREAMING_SNAKE_CASE=None		,				_SCREAMING_SNAKE_CASE=None		,				**_SCREAMING_SNAKE_CASE				) ->				int:
								snake_case_				:							str						 =       None
								if "feature_extractor" in kwargs:
										warnings.warn(
										    "The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`"
										    " instead."		,				_SCREAMING_SNAKE_CASE		,				)
										snake_case_				:							str						 =       kwargs.pop("feature_extractor"				)

								snake_case_				:							Tuple						 =       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__(_SCREAMING_SNAKE_CASE		,				_SCREAMING_SNAKE_CASE				)
								snake_case_				:							str						 =       self.image_processor






						def __call__(	self		,				_SCREAMING_SNAKE_CASE		,				_SCREAMING_SNAKE_CASE = None		,				_SCREAMING_SNAKE_CASE = True		,				_SCREAMING_SNAKE_CASE = False		,				_SCREAMING_SNAKE_CASE = None		,				_SCREAMING_SNAKE_CASE = None		,				_SCREAMING_SNAKE_CASE = 0		,				_SCREAMING_SNAKE_CASE = None		,				_SCREAMING_SNAKE_CASE = None		,				_SCREAMING_SNAKE_CASE = None		,				_SCREAMING_SNAKE_CASE = False		,				_SCREAMING_SNAKE_CASE = False		,				_SCREAMING_SNAKE_CASE = False		,				_SCREAMING_SNAKE_CASE = False		,				_SCREAMING_SNAKE_CASE = True		,				_SCREAMING_SNAKE_CASE = None		,				**_SCREAMING_SNAKE_CASE		,				) ->				BatchEncoding:
								snake_case_				:							List[Any]						 =       self.tokenizer(
								    text=_SCREAMING_SNAKE_CASE		,				add_special_tokens=_SCREAMING_SNAKE_CASE		,				padding=_SCREAMING_SNAKE_CASE		,				truncation=_SCREAMING_SNAKE_CASE		,				max_length=_SCREAMING_SNAKE_CASE		,				stride=_SCREAMING_SNAKE_CASE		,				pad_to_multiple_of=_SCREAMING_SNAKE_CASE		,				return_token_type_ids=_SCREAMING_SNAKE_CASE		,				return_attention_mask=_SCREAMING_SNAKE_CASE		,				return_overflowing_tokens=_SCREAMING_SNAKE_CASE		,				return_special_tokens_mask=_SCREAMING_SNAKE_CASE		,				return_offsets_mapping=_SCREAMING_SNAKE_CASE		,				return_length=_SCREAMING_SNAKE_CASE		,				verbose=_SCREAMING_SNAKE_CASE		,				return_tensors=_SCREAMING_SNAKE_CASE		,				**_SCREAMING_SNAKE_CASE		,				)
								# add pixel_values + pixel_mask
								snake_case_				:							str						 =       self.image_processor(_SCREAMING_SNAKE_CASE		,				return_tensors=_SCREAMING_SNAKE_CASE				)
								encoding.update(_SCREAMING_SNAKE_CASE				)

								return encoding






						def       _lowerCAmelCase       (	self		,				*_SCREAMING_SNAKE_CASE		,				**_SCREAMING_SNAKE_CASE				) ->				List[str]:
								return self.tokenizer.batch_decode(*_SCREAMING_SNAKE_CASE		,				**_SCREAMING_SNAKE_CASE				)






						def       _lowerCAmelCase       (	self		,				*_SCREAMING_SNAKE_CASE		,				**_SCREAMING_SNAKE_CASE				) ->				Dict:
								return self.tokenizer.decode(*_SCREAMING_SNAKE_CASE		,				**_SCREAMING_SNAKE_CASE				)






						@property
						def       _lowerCAmelCase       (	self				) ->				Tuple:
								snake_case_				:							List[Any]						 =       self.tokenizer.model_input_names
								snake_case_				:							Tuple						 =       self.image_processor.model_input_names
								return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names				)				)






						@property
						def       _lowerCAmelCase       (	self				) ->				Optional[Any]:
								warnings.warn(
								    "`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead."		,				_SCREAMING_SNAKE_CASE		,				)
								return self.image_processor_class






						@property
						def       _lowerCAmelCase       (	self				) ->				Optional[int]:
								warnings.warn(
								    "`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead."		,				_SCREAMING_SNAKE_CASE		,				)
								return self.image_processor
