





'''simple docstring'''





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


__lowerCamelCase :  List[str]										=  logging.get_logger(__name__)

__lowerCamelCase :  List[str]										=  {
    """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       A__     ( __snake_case    ):
      _UpperCAmelCase			:Tuple							=     'segformer'





      def __init__(				self ,							A_=3 ,							A_=4 ,							A_=[2, 2, 2, 2] ,							A_=[8, 4, 2, 1] ,							A_=[32, 64, 160, 256] ,							A_=[7, 3, 3, 3] ,							A_=[4, 2, 2, 2] ,							A_=[1, 2, 5, 8] ,							A_=[4, 4, 4, 4] ,							A_="gelu" ,							A_=0.0 ,							A_=0.0 ,							A_=0.1 ,							A_=0.02 ,							A_=0.1 ,							A_=1e-6 ,							A_=256 ,							A_=255 ,							**A_ ,							):
       '''simple docstring'''




       super().__init__(**A_     )

       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." ,							A_ ,							)

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



class       A__     ( __snake_case    ):
      _UpperCAmelCase			:Tuple							=     version.parse('1.11'    )





      @property
      def  __UpperCamelCase(				self     ):
       '''simple docstring'''




       return OrderedDict(
           [
               ("pixel_values", {0: "batch", 1: "num_channels", 2: "height", 3: "width"}),
           ]     )





      @property
      def  __UpperCamelCase(				self     ):
       '''simple docstring'''




       return 1e-4





      @property
      def  __UpperCamelCase(				self     ):
       '''simple docstring'''




       return 12







from typing import List, Optional, Union

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



class       A__     ( __snake_case    ):
      _UpperCAmelCase			:Optional[int]							=     ['image_processor', 'tokenizer']
      _UpperCAmelCase			:Tuple							=     'BlipImageProcessor'
      _UpperCAmelCase			:Optional[int]							=     'AutoTokenizer'





      def __init__(				self ,							A_ ,							A_     ):
       '''simple docstring'''




       UpperCamelCase			:      str 			=     False
       super().__init__(A_ ,							A_     )
       UpperCamelCase			:      str 			=     self.image_processor





      def __call__(				self ,							A_ = None ,							A_ = None ,							A_ = True ,							A_ = False ,							A_ = None ,							A_ = None ,							A_ = 0 ,							A_ = None ,							A_ = None ,							A_ = False ,							A_ = False ,							A_ = False ,							A_ = False ,							A_ = False ,							A_ = True ,							A_ = None ,							**A_ ,							):
       '''simple docstring'''




       if images is None and text is None:
        raise ValueError("You have to specify either images or text."     )

       # Get only text
       if images is None:
        UpperCamelCase			:      int 			=     self.tokenizer
        UpperCamelCase			:      Optional[int] 			=     self.tokenizer(
            text=A_ ,							add_special_tokens=A_ ,							padding=A_ ,							truncation=A_ ,							max_length=A_ ,							stride=A_ ,							pad_to_multiple_of=A_ ,							return_attention_mask=A_ ,							return_overflowing_tokens=A_ ,							return_special_tokens_mask=A_ ,							return_offsets_mapping=A_ ,							return_token_type_ids=A_ ,							return_length=A_ ,							verbose=A_ ,							return_tensors=A_ ,							**A_ ,							)
        return text_encoding

       # add pixel_values
       UpperCamelCase			:      int 			=     self.image_processor(A_ ,							return_tensors=A_     )

       if text is not None:
        UpperCamelCase			:      Dict 			=     self.tokenizer(
            text=A_ ,							add_special_tokens=A_ ,							padding=A_ ,							truncation=A_ ,							max_length=A_ ,							stride=A_ ,							pad_to_multiple_of=A_ ,							return_attention_mask=A_ ,							return_overflowing_tokens=A_ ,							return_special_tokens_mask=A_ ,							return_offsets_mapping=A_ ,							return_token_type_ids=A_ ,							return_length=A_ ,							verbose=A_ ,							return_tensors=A_ ,							**A_ ,							)
       else:
        UpperCamelCase			:      Dict 			=     None

       if text_encoding is not None:
        encoding_image_processor.update(A_     )

       return encoding_image_processor





      def  __UpperCamelCase(				self ,							*A_ ,							**A_     ):
       '''simple docstring'''




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





      def  __UpperCamelCase(				self ,							*A_ ,							**A_     ):
       '''simple docstring'''




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





      @property
      # Copied from transformers.models.blip.processing_blip.BlipProcessor.model_input_names
      def  __UpperCamelCase(				self     ):
       '''simple docstring'''




       UpperCamelCase			:      List[str] 			=     self.tokenizer.model_input_names
       UpperCamelCase			:      int 			=     self.image_processor.model_input_names
       return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names     )     )
