



'''simple docstring'''







import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin




class 				__lowerCAmelCase(							lowerCAmelCase__      ):
			__snake_case  :		List[str]		=      ['image_processor', 'tokenizer']
			__snake_case  :		Tuple		=      'AutoImageProcessor'
			__snake_case  :		str		=      'AutoTokenizer'






			def __init__(   self  :							List[str]      ,       SCREAMING_SNAKE_CASE  :							Optional[Any]=None      ,       SCREAMING_SNAKE_CASE  :							List[str]=None      ,       **SCREAMING_SNAKE_CASE  :							str	):




					"""simple docstring"""







					SCREAMING_SNAKE_CASE_						:Dict										=      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      ,       )
							SCREAMING_SNAKE_CASE_						:str										=      kwargs.pop('feature_extractor'	)

					SCREAMING_SNAKE_CASE_						:Optional[Any]										=      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	)
					SCREAMING_SNAKE_CASE_						:Tuple										=      self.image_processor
					SCREAMING_SNAKE_CASE_						:Union[str, Any]										=      False






			def __call__(   self  :							Optional[Any]      ,       *SCREAMING_SNAKE_CASE  :							Union[str, Any]      ,       **SCREAMING_SNAKE_CASE  :							Tuple	):




					"""simple docstring"""







					if self._in_target_context_manager:
							return self.current_processor(*SCREAMING_SNAKE_CASE      ,       **SCREAMING_SNAKE_CASE	)

					SCREAMING_SNAKE_CASE_						:str										=      kwargs.pop('images'      ,       SCREAMING_SNAKE_CASE	)
					SCREAMING_SNAKE_CASE_						:str										=      kwargs.pop('text'      ,       SCREAMING_SNAKE_CASE	)
					if len(SCREAMING_SNAKE_CASE	) > 0:
							SCREAMING_SNAKE_CASE_						:Optional[Any]										=      args[0]
							SCREAMING_SNAKE_CASE_						:Optional[int]										=      args[1:]

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

					if images is not None:
							SCREAMING_SNAKE_CASE_						:Tuple										=      self.image_processor(SCREAMING_SNAKE_CASE      ,       *SCREAMING_SNAKE_CASE      ,       **SCREAMING_SNAKE_CASE	)
					if text is not None:
							SCREAMING_SNAKE_CASE_						:int										=      self.tokenizer(SCREAMING_SNAKE_CASE      ,       **SCREAMING_SNAKE_CASE	)

					if text is None:
							return inputs
					elif images is None:
							return encodings
					else:
							SCREAMING_SNAKE_CASE_						:int										=      encodings['input_ids']
							return inputs






			def 				_lowercase	(   self  :							Dict      ,       *SCREAMING_SNAKE_CASE  :							Dict      ,       **SCREAMING_SNAKE_CASE  :							Any	):




					"""simple docstring"""







					return self.tokenizer.batch_decode(*SCREAMING_SNAKE_CASE      ,       **SCREAMING_SNAKE_CASE	)






			def 				_lowercase	(   self  :							Optional[Any]      ,       *SCREAMING_SNAKE_CASE  :							str      ,       **SCREAMING_SNAKE_CASE  :							Optional[int]	):




					"""simple docstring"""







					return self.tokenizer.decode(*SCREAMING_SNAKE_CASE      ,       **SCREAMING_SNAKE_CASE	)






			@contextmanager
			def 				_lowercase	(   self  :							Optional[Any]	):




					"""simple docstring"""







					warnings.warn(
					    '`as_target_processor` is deprecated and will be removed in v5 of Transformers. You can process your '
					    'labels by using the argument `text` of the regular `__call__` method (either in the same call as '
					    'your images inputs, or in a separate call.'	)
					SCREAMING_SNAKE_CASE_						:Union[str, Any]										=      True
					SCREAMING_SNAKE_CASE_						:str										=      self.tokenizer
					yield
					SCREAMING_SNAKE_CASE_						:int										=      self.image_processor
					SCREAMING_SNAKE_CASE_						:int										=      False






			@property
			def 				_lowercase	(   self  :							Union[str, Any]	):




					"""simple docstring"""







					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 				_lowercase	(   self  :							Dict	):




					"""simple docstring"""







					warnings.warn(
					    '`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead.'      ,       SCREAMING_SNAKE_CASE      ,       )
					return self.image_processor



"""simple docstring"""

from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_tf_available,
    is_torch_available,
    is_vision_available,
)


a__			:						Tuple							=			{
    """configuration_segformer""": ["""SEGFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """SegformerConfig""", """SegformerOnnxConfig"""]
}

try:
							if not is_vision_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							a__			:						List[str]							=			["""SegformerFeatureExtractor"""]
							a__			:						str							=			["""SegformerImageProcessor"""]

try:
							if not is_torch_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							a__			:						Optional[Any]							=			[
							    """SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST""",
							    """SegformerDecodeHead""",
							    """SegformerForImageClassification""",
							    """SegformerForSemanticSegmentation""",
							    """SegformerLayer""",
							    """SegformerModel""",
							    """SegformerPreTrainedModel""",
							]

try:
							if not is_tf_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							a__			:						List[Any]							=			[
							    """TF_SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST""",
							    """TFSegformerDecodeHead""",
							    """TFSegformerForImageClassification""",
							    """TFSegformerForSemanticSegmentation""",
							    """TFSegformerModel""",
							    """TFSegformerPreTrainedModel""",
							]


if TYPE_CHECKING:
							from .configuration_segformer import SEGFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP, SegformerConfig, SegformerOnnxConfig

							try:
														if not is_vision_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .feature_extraction_segformer import SegformerFeatureExtractor
														from .image_processing_segformer import SegformerImageProcessor

							try:
														if not is_torch_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_segformer import (
														    SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
														    SegformerDecodeHead,
														    SegformerForImageClassification,
														    SegformerForSemanticSegmentation,
														    SegformerLayer,
														    SegformerModel,
														    SegformerPreTrainedModel,
														)
							try:
														if not is_tf_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_tf_segformer import (
														    TF_SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
														    TFSegformerDecodeHead,
														    TFSegformerForImageClassification,
														    TFSegformerForSemanticSegmentation,
														    TFSegformerModel,
														    TFSegformerPreTrainedModel,
														)

else:
							import sys

							a__			:						Any							=			_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)


