






import warnings

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


class  SCREAMING_SNAKE_CASE			(			lowerCAmelCase					):
     '''simple docstring'''


     UpperCamelCase_							:		List[Any]			=	['''image_processor''', '''tokenizer''']
     UpperCamelCase_							:		Union[str, Any]			=	'''ViTImageProcessor'''
     UpperCamelCase_							:		Optional[Any]			=	('''CLIPTokenizer''', '''CLIPTokenizerFast''')


     def __init__(				self       :	Union[str, Any]					, UpperCAmelCase_       :	Optional[Any]=None					, UpperCAmelCase_       :	List[Any]=None					, **UpperCAmelCase_       :	Optional[int]      ):
       SCREAMING_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."					, UpperCAmelCase_					, )
         SCREAMING_SNAKE_CASE       :      List[str]							=    kwargs.pop("feature_extractor"      )

       SCREAMING_SNAKE_CASE       :      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__(UpperCAmelCase_					, UpperCAmelCase_      )


     def __call__(				self       :	int					, UpperCAmelCase_       :	int=None					, UpperCAmelCase_       :	str=None					, UpperCAmelCase_       :	Any=None					, UpperCAmelCase_       :	Union[str, Any]=None					, **UpperCAmelCase_       :	Any      ):
       if text is None and visual_prompt is None and images is None:
         raise ValueError("You have to specify either text, visual prompt or images."      )

       if text is not None and visual_prompt is not None:
         raise ValueError("You have to specify exactly one type of prompt. Either text or visual prompt."      )

       if text is not None:
         SCREAMING_SNAKE_CASE       :      Any							=    self.tokenizer(UpperCAmelCase_					, return_tensors=UpperCAmelCase_					, **UpperCAmelCase_      )

       if visual_prompt is not None:
         SCREAMING_SNAKE_CASE       :      Optional[Any]							=    self.image_processor(UpperCAmelCase_					, return_tensors=UpperCAmelCase_					, **UpperCAmelCase_      )

       if images is not None:
         SCREAMING_SNAKE_CASE       :      Tuple							=    self.image_processor(UpperCAmelCase_					, return_tensors=UpperCAmelCase_					, **UpperCAmelCase_      )

       if visual_prompt is not None and images is not None:
         SCREAMING_SNAKE_CASE       :      Optional[int]							=    {
             "pixel_values": image_features.pixel_values,
             "conditional_pixel_values": prompt_features.pixel_values,
         }
         return encoding
       elif text is not None and images is not None:
         SCREAMING_SNAKE_CASE       :      Optional[int]							=    image_features.pixel_values
         return encoding
       elif text is not None:
         return encoding
       elif visual_prompt is not None:
         SCREAMING_SNAKE_CASE       :      Union[str, Any]							=    {
             "conditional_pixel_values": prompt_features.pixel_values,
         }
         return encoding
       else:
         return BatchEncoding(data=dict(**UpperCAmelCase_      )					, tensor_type=UpperCAmelCase_      )


     def 				_A       (				self       :	Optional[Any]					, *UpperCAmelCase_       :	str					, **UpperCAmelCase_       :	List[Any]      ):
       return self.tokenizer.batch_decode(*UpperCAmelCase_					, **UpperCAmelCase_      )


     def 				_A       (				self       :	Tuple					, *UpperCAmelCase_       :	int					, **UpperCAmelCase_       :	int      ):
       return self.tokenizer.decode(*UpperCAmelCase_					, **UpperCAmelCase_      )


     @property
     def 				_A       (				self       :	Optional[int]      ):
       warnings.warn(
           "`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead."					, UpperCAmelCase_					, )
       return self.image_processor_class






     @property
     def 				_A       (				self       :	List[str]      ):
       warnings.warn(
           "`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead."					, UpperCAmelCase_					, )
       return self.image_processor














import warnings
from collections import OrderedDict
from typing import Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


snake_case    				=		logging.get_logger(__name__)

snake_case    				=		{
    """nvidia/segformer-b0-finetuned-ade-512-512""": (
        """https://huggingface.co/nvidia/segformer-b0-finetuned-ade-512-512/resolve/main/config.json"""
    ),
    # See all SegFormer models at https://huggingface.co/models?filter=segformer
}


class  SCREAMING_SNAKE_CASE			(			lowerCAmelCase					):
     '''simple docstring'''


     UpperCamelCase_							:		str			=	'''segformer'''


     def __init__(				self       :	List[Any]					, UpperCAmelCase_       :	int=3					, UpperCAmelCase_       :	Optional[Any]=4					, UpperCAmelCase_       :	List[str]=[2, 2, 2, 2]					, UpperCAmelCase_       :	Optional[int]=[8, 4, 2, 1]					, UpperCAmelCase_       :	Union[str, Any]=[32, 64, 160, 256]					, UpperCAmelCase_       :	int=[7, 3, 3, 3]					, UpperCAmelCase_       :	str=[4, 2, 2, 2]					, UpperCAmelCase_       :	List[str]=[1, 2, 5, 8]					, UpperCAmelCase_       :	List[Any]=[4, 4, 4, 4]					, UpperCAmelCase_       :	Dict="gelu"					, UpperCAmelCase_       :	Optional[Any]=0.0					, UpperCAmelCase_       :	Optional[Any]=0.0					, UpperCAmelCase_       :	int=0.1					, UpperCAmelCase_       :	List[Any]=0.02					, UpperCAmelCase_       :	Optional[int]=0.1					, UpperCAmelCase_       :	Optional[Any]=1E-6					, UpperCAmelCase_       :	List[str]=256					, UpperCAmelCase_       :	Dict=255					, **UpperCAmelCase_       :	Dict					, ):
       super().__init__(**UpperCAmelCase_      )

       if "reshape_last_stage" in kwargs and kwargs["reshape_last_stage"] is False:
         warnings.warn(
             "Reshape_last_stage is set to False in this config. This argument is deprecated and will soon be"
             " removed, as the behaviour will default to that of reshape_last_stage = True."					, UpperCAmelCase_					, )

       SCREAMING_SNAKE_CASE       :      Dict							=    num_channels
       SCREAMING_SNAKE_CASE       :      Any							=    num_encoder_blocks
       SCREAMING_SNAKE_CASE       :      Tuple							=    depths
       SCREAMING_SNAKE_CASE       :      Any							=    sr_ratios
       SCREAMING_SNAKE_CASE       :      Union[str, Any]							=    hidden_sizes
       SCREAMING_SNAKE_CASE       :      int							=    patch_sizes
       SCREAMING_SNAKE_CASE       :      Optional[int]							=    strides
       SCREAMING_SNAKE_CASE       :      Tuple							=    mlp_ratios
       SCREAMING_SNAKE_CASE       :      Any							=    num_attention_heads
       SCREAMING_SNAKE_CASE       :      int							=    hidden_act
       SCREAMING_SNAKE_CASE       :      Optional[Any]							=    hidden_dropout_prob
       SCREAMING_SNAKE_CASE       :      str							=    attention_probs_dropout_prob
       SCREAMING_SNAKE_CASE       :      Tuple							=    classifier_dropout_prob
       SCREAMING_SNAKE_CASE       :      List[Any]							=    initializer_range
       SCREAMING_SNAKE_CASE       :      Dict							=    drop_path_rate
       SCREAMING_SNAKE_CASE       :      Any							=    layer_norm_eps
       SCREAMING_SNAKE_CASE       :      Any							=    decoder_hidden_size
       SCREAMING_SNAKE_CASE       :      Union[str, Any]							=    kwargs.get("reshape_last_stage"					, UpperCAmelCase_      )
       SCREAMING_SNAKE_CASE       :      List[str]							=    semantic_loss_ignore_index





class  SCREAMING_SNAKE_CASE			(			lowerCAmelCase					):
     '''simple docstring'''


     UpperCamelCase_							:		Dict			=	version.parse('''1.11'''					)


     @property
     def 				_A       (				self       :	Optional[Any]      ):
       return OrderedDict(
           [
               ("pixel_values", {0: "batch", 1: "num_channels", 2: "height", 3: "width"}),
           ]      )


     @property
     def 				_A       (				self       :	List[str]      ):
       return 1E-4






     @property
     def 				_A       (				self       :	Any      ):
       return 12






