




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


_snake_case				:				Any       							=		logging.get_logger(__name__)

_snake_case				:				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   (		_a   ):
							lowercase_          =    'segformer'







							def __init__(  self	:  Optional[Any]							,      lowerCAmelCase_	:  Any=3							,      lowerCAmelCase_	:  Optional[int]=4							,      lowerCAmelCase_	:  Any=[2, 2, 2, 2]							,      lowerCAmelCase_	:  Tuple=[8, 4, 2, 1]							,      lowerCAmelCase_	:  List[Any]=[32, 64, 1_60, 2_56]							,      lowerCAmelCase_	:  List[Any]=[7, 3, 3, 3]							,      lowerCAmelCase_	:  Any=[4, 2, 2, 2]							,      lowerCAmelCase_	:  List[Any]=[1, 2, 5, 8]							,      lowerCAmelCase_	:  Union[str, Any]=[4, 4, 4, 4]							,      lowerCAmelCase_	:  Optional[int]="gelu"							,      lowerCAmelCase_	:  str=0.0							,      lowerCAmelCase_	:  str=0.0							,      lowerCAmelCase_	:  Optional[int]=0.1							,      lowerCAmelCase_	:  Union[str, Any]=0.0_2							,      lowerCAmelCase_	:  List[Any]=0.1							,      lowerCAmelCase_	:  List[Any]=1e-6							,      lowerCAmelCase_	:  int=2_56							,      lowerCAmelCase_	:  Dict=2_55							,      **lowerCAmelCase_	:  str							,      )      ->							List[Any]:


														"""simple docstring"""


														super().__init__(**lowerCAmelCase_ )

														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.'''							,      lowerCAmelCase_							,      )

														_a     					=    num_channels
														_a     					=    num_encoder_blocks
														_a     					=    depths
														_a     					=    sr_ratios
														_a     					=    hidden_sizes
														_a     					=    patch_sizes
														_a     					=    strides
														_a     					=    mlp_ratios
														_a     					=    num_attention_heads
														_a     					=    hidden_act
														_a     					=    hidden_dropout_prob
														_a     					=    attention_probs_dropout_prob
														_a     					=    classifier_dropout_prob
														_a     					=    initializer_range
														_a     					=    drop_path_rate
														_a     					=    layer_norm_eps
														_a     					=    decoder_hidden_size
														_a     					=    kwargs.get('''reshape_last_stage'''							,      lowerCAmelCase_ )
														_a     					=    semantic_loss_ignore_index



class       A   (		_a   ):
							lowercase_          =    version.parse('1.11'   )







							@property
							def        __lowerCAmelCase      (  self	:  Optional[Any] )      ->							Mapping[str, Mapping[int, str]]:


														"""simple docstring"""


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







							@property
							def        __lowerCAmelCase      (  self	:  str )      ->							float:


														"""simple docstring"""


														return 1e-4







							@property
							def        __lowerCAmelCase      (  self	:  Union[str, Any] )      ->							int:


														"""simple docstring"""


														return 12







'''simple docstring'''


import copy
import random

from transformers import CLIPTokenizer

class       A   (		_a   ):







							def __init__(  self	:  str							,      *lowerCAmelCase_	:  int							,      **lowerCAmelCase_	:  List[str] )      ->							List[Any]:


														"""simple docstring"""


														super().__init__(*lowerCAmelCase_							,      **lowerCAmelCase_ )
														_a     					=    {}







							def        __lowerCAmelCase      (  self	:  Any							,      lowerCAmelCase_	:  Tuple							,      *lowerCAmelCase_	:  Any							,      **lowerCAmelCase_	:  Tuple )      ->							str:


														"""simple docstring"""


														_a     					=    super().add_tokens(lowerCAmelCase_							,      *lowerCAmelCase_							,      **lowerCAmelCase_ )
														if num_added_tokens == 0:
																					raise ValueError(
																					    F'The tokenizer already contains the token {placeholder_token}. Please pass a different'
																					    ''' `placeholder_token` that is not already in the tokenizer.''' )







							def        __lowerCAmelCase      (  self	:  Optional[Any]							,      lowerCAmelCase_	:  Dict							,      *lowerCAmelCase_	:  Tuple							,      lowerCAmelCase_	:  Tuple=1							,      **lowerCAmelCase_	:  int )      ->							Any:


														"""simple docstring"""


														_a     					=    []
														if num_vec_per_token == 1:
																					self.try_adding_tokens(lowerCAmelCase_							,      *lowerCAmelCase_							,      **lowerCAmelCase_ )
																					output.append(lowerCAmelCase_ )
														else:
																					_a     					=    []
																					for i in range(lowerCAmelCase_ ):
																												_a     					=    placeholder_token + F'_{i}'
																												self.try_adding_tokens(lowerCAmelCase_							,      *lowerCAmelCase_							,      **lowerCAmelCase_ )
																												output.append(lowerCAmelCase_ )
        # handle cases where there is a new placeholder token that contains the current placeholder token but is larger
														for token in self.token_map:
																					if token in placeholder_token:
																												raise ValueError(
																												    F'The tokenizer already has placeholder token {token} that can get confused with'
																												    F' {placeholder_token}keep placeholder tokens independent' )
														_a     					=    output







							def        __lowerCAmelCase      (  self	:  Dict							,      lowerCAmelCase_	:  List[Any]							,      lowerCAmelCase_	:  Tuple=False							,      lowerCAmelCase_	:  Optional[int]=1.0 )      ->							Tuple:


														"""simple docstring"""


														if isinstance(lowerCAmelCase_							,      lowerCAmelCase_ ):
																					_a     					=    []
																					for i in range(len(lowerCAmelCase_ ) ):
																												output.append(self.replace_placeholder_tokens_in_text(text[i]							,      vector_shuffle=lowerCAmelCase_ ) )
																					return output
														for placeholder_token in self.token_map:
																					if placeholder_token in text:
																												_a     					=    self.token_map[placeholder_token]
																												_a     					=    tokens[: 1 + int(len(lowerCAmelCase_ ) * prop_tokens_to_load )]
																												if vector_shuffle:
																																			_a     					=    copy.copy(lowerCAmelCase_ )
																																			random.shuffle(lowerCAmelCase_ )
																												_a     					=    text.replace(lowerCAmelCase_							,      ''' '''.join(lowerCAmelCase_ ) )
														return text







							def __call__(  self	:  List[str]							,      lowerCAmelCase_	:  str							,      *lowerCAmelCase_	:  int							,      lowerCAmelCase_	:  Optional[int]=False							,      lowerCAmelCase_	:  Union[str, Any]=1.0							,      **lowerCAmelCase_	:  Union[str, Any] )      ->							Union[str, Any]:


														"""simple docstring"""


														return super().__call__(
														    self.replace_placeholder_tokens_in_text(
														        lowerCAmelCase_							,      vector_shuffle=lowerCAmelCase_							,      prop_tokens_to_load=lowerCAmelCase_ )							,      *lowerCAmelCase_							,      **lowerCAmelCase_							,      )







							def        __lowerCAmelCase      (  self	:  List[str]							,      lowerCAmelCase_	:  int							,      *lowerCAmelCase_	:  str							,      lowerCAmelCase_	:  Any=False							,      lowerCAmelCase_	:  List[Any]=1.0							,      **lowerCAmelCase_	:  Union[str, Any] )      ->							Dict:


														"""simple docstring"""


														return super().encode(
														    self.replace_placeholder_tokens_in_text(
														        lowerCAmelCase_							,      vector_shuffle=lowerCAmelCase_							,      prop_tokens_to_load=lowerCAmelCase_ )							,      *lowerCAmelCase_							,      **lowerCAmelCase_							,      )

