




'''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


UpperCamelCase_    	=				logging.get_logger(__name__)

UpperCamelCase_    	=				{
    "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				(			SCREAMING_SNAKE_CASE ):





       '''simple docstring'''






       A						:				Any        =						'''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,							)

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






class 							_a				(			SCREAMING_SNAKE_CASE ):





       '''simple docstring'''






       A						:				Optional[int]        =						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








'''simple docstring'''



from typing import Dict

from .base import GenericTensor, Pipeline






class 							_a				(			SCREAMING_SNAKE_CASE ):





       '''simple docstring'''






       def        UpperCamelCase_							(      self,							A=None,							A=None,							A=None,							**A  ):







             '''simple docstring'''







             if tokenize_kwargs is None:
                   SCREAMING_SNAKE_CASE   :      Optional[int]    					=						{}

             if truncation is not None:
                   if "truncation" in tokenize_kwargs:
                         raise ValueError(
                             'truncation parameter defined twice (given as keyword argument as well as in tokenize_kwargs)'  )
                   SCREAMING_SNAKE_CASE   :      Tuple    					=						truncation

             SCREAMING_SNAKE_CASE   :      int    					=						tokenize_kwargs

             SCREAMING_SNAKE_CASE   :      Optional[Any]    					=						{}
             if return_tensors is not None:
                   SCREAMING_SNAKE_CASE   :      Optional[int]    					=						return_tensors

             return preprocess_params, {}, postprocess_params







       def        UpperCamelCase_							(      self,							A,							**A  ):







             '''simple docstring'''







             SCREAMING_SNAKE_CASE   :      Tuple    					=						self.framework
             SCREAMING_SNAKE_CASE   :      Tuple    					=						self.tokenizer(A,							return_tensors=A,							**A  )
             return model_inputs







       def        UpperCamelCase_							(      self,							A  ):







             '''simple docstring'''







             SCREAMING_SNAKE_CASE   :      Any    					=						self.model(**A  )
             return model_outputs







       def        UpperCamelCase_							(      self,							A,							A=False  ):







             '''simple docstring'''







             if return_tensors:
                   return model_outputs[0]
             if self.framework == "pt":
                   return model_outputs[0].tolist()
             elif self.framework == "tf":
                   return model_outputs[0].numpy().tolist()







       def __call__(      self,							*A,							**A  ):







             '''simple docstring'''







             return super().__call__(*A,							**A  )


