'''simple docstring'''





import builtins
import sys

from ...utils.imports import _is_package_available
from . import cursor, input
from .helpers import Direction, clear_line, forceWrite, linebreak, move_cursor, reset_cursor, writeColor
from .keymap import KEYMAP


UpperCAmelCase_								=							False
try:
      UpperCAmelCase_								=							_is_package_available('''google.colab''')
except ModuleNotFoundError:
      pass





@input.register
class      lowerCAmelCase						:



     def __init__(					self				,      lowerCAmelCase__ = None				,      lowerCAmelCase__ = []       ):
            _A=	0
            _A=	choices
            _A=	prompt
            if sys.platform == "win32":
                   _A=	'*'
            else:
                   _A=	'➔ '



     def 			a__  (					self				,      lowerCAmelCase__				,      lowerCAmelCase__ = ""       ):
            if sys.platform != "win32":
                   writeColor(self.choices[index]				,      32				,      lowerCAmelCase__       )
            else:
                   forceWrite(self.choices[index]				,      lowerCAmelCase__       )



     def 			a__  (					self				,      lowerCAmelCase__       ):
            if index == self.position:
                   forceWrite(f" {self.arrow_char} "       )
                   self.write_choice(lowerCAmelCase__       )
            else:
                   forceWrite(f"    {self.choices[index]}"       )
            reset_cursor()



     def 			a__  (					self				,      lowerCAmelCase__				,      lowerCAmelCase__ = 1       ):
            _A=	self.position
            if direction == Direction.DOWN:
                   if self.position + 1 >= len(self.choices       ):
                          return
                   self.position += num_spaces
            else:
                   if self.position - 1 < 0:
                          return
                   self.position -= num_spaces
            clear_line()
            self.print_choice(lowerCAmelCase__       )
            move_cursor(lowerCAmelCase__				,      direction.name       )
            self.print_choice(self.position       )



     @input.mark(KEYMAP['up']       )
     def 			a__  (					self       ):
            self.move_direction(Direction.UP       )



     @input.mark(KEYMAP['down']       )
     def 			a__  (					self       ):
            self.move_direction(Direction.DOWN       )



     @input.mark(KEYMAP['newline']       )
     def 			a__  (					self       ):
            move_cursor(len(self.choices       ) - self.position				,      'DOWN'       )
            return self.position



     @input.mark(KEYMAP['interrupt']       )
     def 			a__  (					self       ):
            move_cursor(len(self.choices       ) - self.position				,      'DOWN'       )
            raise KeyboardInterrupt



     @input.mark_multiple(*[KEYMAP[str(lowerCAmelCase__       )] for number in range(10       )]       )
     def 			a__  (					self       ):
            _A=	int(chr(self.current_selection       )       )
            _A=	index - self.position
            if index == self.position:
                   return
            if index < len(self.choices       ):
                   if self.position > index:
                          self.move_direction(Direction.UP				,      -movement       )
                   elif self.position < index:
                          self.move_direction(Direction.DOWN				,      lowerCAmelCase__       )
                   else:
                          return
            else:
                   return





     def 			a__  (					self				,      lowerCAmelCase__ = 0       ):
            if self.prompt:
                   linebreak()
                   forceWrite(self.prompt				,      '\n'       )
                   if in_colab:
                          forceWrite('Please input a choice index (starting from 0), and press enter'				,      '\n'       )
                   else:
                          forceWrite('Please select a choice using the arrow or number keys, and selecting with enter'				,      '\n'       )
            _A=	default_choice
            for i in range(len(self.choices       )       ):
                   self.print_choice(lowerCAmelCase__       )
                   forceWrite('\n'       )
            move_cursor(len(self.choices       ) - self.position				,      'UP'       )
            with cursor.hide():
                   while True:
                          if in_colab:
                                 try:
                                        _A=	int(builtins.input()       )
                                 except ValueError:
                                        _A=	default_choice
                          else:
                                 _A=	self.handle_input()
                          if choice is not None:
                                 reset_cursor()
                                 for _ in range(len(self.choices       ) + 1       ):
                                        move_cursor(1				,      'UP'       )
                                        clear_line()
                                 self.write_choice(lowerCAmelCase__				,      '\n'       )
                                 return choice
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      lowerCAmelCase						(					_a			):
     _SCREAMING_SNAKE_CASE     :     Tuple		="""segformer"""



     def __init__(					self				,      lowerCAmelCase__=3				,      lowerCAmelCase__=4				,      lowerCAmelCase__=[2, 2, 2, 2]				,      lowerCAmelCase__=[8, 4, 2, 1]				,      lowerCAmelCase__=[32, 64, 160, 256]				,      lowerCAmelCase__=[7, 3, 3, 3]				,      lowerCAmelCase__=[4, 2, 2, 2]				,      lowerCAmelCase__=[1, 2, 5, 8]				,      lowerCAmelCase__=[4, 4, 4, 4]				,      lowerCAmelCase__="gelu"				,      lowerCAmelCase__=0.0				,      lowerCAmelCase__=0.0				,      lowerCAmelCase__=0.1				,      lowerCAmelCase__=0.02				,      lowerCAmelCase__=0.1				,      lowerCAmelCase__=1E-6				,      lowerCAmelCase__=256				,      lowerCAmelCase__=255				,      **lowerCAmelCase__				,      ):
            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      lowerCAmelCase						(					_a			):
     _SCREAMING_SNAKE_CASE     :     List[str]		=version.parse("""1.11"""			)



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



     @property
     def 			a__  (					self       ):
            return 1E-4





     @property
     def 			a__  (					self       ):
            return 12