


import os
import string
import sys


__UpperCAmelCase : Optional[Any] 			=				1 << 8

__UpperCAmelCase : List[Any] 			=				{
    "tab": ord("\t"),
    "newline": ord("\r"),
    "esc": 27,
    "up": 65 + ARROW_KEY_FLAG,
    "down": 66 + ARROW_KEY_FLAG,
    "right": 67 + ARROW_KEY_FLAG,
    "left": 68 + ARROW_KEY_FLAG,
    "mod_int": 91,
    "undefined": sys.maxsize,
    "interrupt": 3,
    "insert": 50,
    "delete": 51,
    "pg_up": 53,
    "pg_down": 54,
}

__UpperCAmelCase : Dict 			=				KEYMAP["up"]
__UpperCAmelCase : Union[str, Any] 			=				KEYMAP["left"]

if sys.platform == "win32":
  __UpperCAmelCase : List[str] 			=				[]
  __UpperCAmelCase : List[str] 			=				{
      B"\xe0H": KEYMAP["up"] - ARROW_KEY_FLAG,
      B"\x00H": KEYMAP["up"] - ARROW_KEY_FLAG,
      B"\xe0P": KEYMAP["down"] - ARROW_KEY_FLAG,
      B"\x00P": KEYMAP["down"] - ARROW_KEY_FLAG,
      B"\xe0M": KEYMAP["right"] - ARROW_KEY_FLAG,
      B"\x00M": KEYMAP["right"] - ARROW_KEY_FLAG,
      B"\xe0K": KEYMAP["left"] - ARROW_KEY_FLAG,
      B"\x00K": KEYMAP["left"] - ARROW_KEY_FLAG,
  }

for i in range(10):
  __UpperCAmelCase : Optional[int] 			=				ord(str(i))


def      a	(							):






       """simple docstring"""





       if os.name == "nt":
              import msvcrt

              UpperCamelCase    :	Optional[Any]   	=		'''mbcs'''
              # Flush the keyboard buffer
              while msvcrt.kbhit():
                     msvcrt.getch()
              if len(SCREAMING_SNAKE_CASE_       ) == 0:
                     # Read the keystroke
                     UpperCamelCase    :	Optional[Any]   	=		msvcrt.getch()

                     # If it is a prefix char, get second part
                     if ch in (b"\x00", b"\xe0"):
                            UpperCamelCase    :	Tuple   	=		ch + msvcrt.getch()
                            # Translate actual Win chars to bullet char types
                            try:
                                   UpperCamelCase    :	List[Any]   	=		chr(WIN_KEYMAP[cha]       )
                                   WIN_CH_BUFFER.append(chr(KEYMAP['''mod_int''']       )       )
                                   WIN_CH_BUFFER.append(SCREAMING_SNAKE_CASE_       )
                                   if ord(SCREAMING_SNAKE_CASE_       ) in (
                                       KEYMAP["insert"] - 1 << 9,
                                       KEYMAP["delete"] - 1 << 9,
                                       KEYMAP["pg_up"] - 1 << 9,
                                       KEYMAP["pg_down"] - 1 << 9,
                                   ):
                                          WIN_CH_BUFFER.append(chr(1_2_6       )       )
                                   UpperCamelCase    :	str   	=		chr(KEYMAP['''esc''']       )
                            except KeyError:
                                   UpperCamelCase    :	List[str]   	=		cha[1]
                     else:
                            UpperCamelCase    :	Dict   	=		ch.decode(SCREAMING_SNAKE_CASE_       )
              else:
                     UpperCamelCase    :	Tuple   	=		WIN_CH_BUFFER.pop(0       )
       elif os.name == "posix":
              import termios
              import tty

              UpperCamelCase    :	str   	=		sys.stdin.fileno()
              UpperCamelCase    :	List[str]   	=		termios.tcgetattr(SCREAMING_SNAKE_CASE_       )
              try:
                     tty.setraw(SCREAMING_SNAKE_CASE_       )
                     UpperCamelCase    :	int   	=		sys.stdin.read(1       )
              finally:
                     termios.tcsetattr(SCREAMING_SNAKE_CASE_							,			termios.TCSADRAIN							,			SCREAMING_SNAKE_CASE_       )
       return ch


def      a	(							):






       """simple docstring"""





       UpperCamelCase    :	List[Any]   	=		get_raw_chars()
       if ord(SCREAMING_SNAKE_CASE_       ) in [KEYMAP["interrupt"], KEYMAP["newline"]]:
              return char

       elif ord(SCREAMING_SNAKE_CASE_       ) == KEYMAP["esc"]:
              UpperCamelCase    :	int   	=		get_raw_chars()
              if ord(SCREAMING_SNAKE_CASE_       ) == KEYMAP["mod_int"]:
                     UpperCamelCase    :	str   	=		get_raw_chars()
                     if ord(SCREAMING_SNAKE_CASE_       ) >= KEYMAP["arrow_begin"] - ARROW_KEY_FLAG and ord(SCREAMING_SNAKE_CASE_       ) <= KEYMAP["arrow_end"] - ARROW_KEY_FLAG:
                            return chr(ord(SCREAMING_SNAKE_CASE_       ) + ARROW_KEY_FLAG       )
                     else:
                            return KEYMAP["undefined"]
              else:
                     return get_raw_chars()

       else:
              if char in string.printable:
                     return char
              else:
                     return KEYMAP["undefined"]





import copy
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
from ..auto import CONFIG_MAPPING


__UpperCAmelCase : Optional[Any] 			=				logging.get_logger(__name__)

__UpperCAmelCase : List[str] 			=				{
    "microsoft/conditional-detr-resnet-50": (
        "https://huggingface.co/microsoft/conditional-detr-resnet-50/resolve/main/config.json"
    ),
}



class    UpperCAmelCase_	(							_a):
       '''simple docstring'''
       __UpperCamelCase      :     Optional[int]							=					"conditional_detr"
       __UpperCamelCase      :     Optional[Any]							=					["past_key_values"]
       __UpperCamelCase      :     Union[str, Any]							=					{
           "hidden_size": "d_model",
           "num_attention_heads": "encoder_attention_heads",
       }






       def __init__(     self ,					__SCREAMING_SNAKE_CASE=True ,					__SCREAMING_SNAKE_CASE=None ,					__SCREAMING_SNAKE_CASE=3 ,					__SCREAMING_SNAKE_CASE=300 ,					__SCREAMING_SNAKE_CASE=6 ,					__SCREAMING_SNAKE_CASE=2_048 ,					__SCREAMING_SNAKE_CASE=8 ,					__SCREAMING_SNAKE_CASE=6 ,					__SCREAMING_SNAKE_CASE=2_048 ,					__SCREAMING_SNAKE_CASE=8 ,					__SCREAMING_SNAKE_CASE=0.0 ,					__SCREAMING_SNAKE_CASE=0.0 ,					__SCREAMING_SNAKE_CASE=True ,					__SCREAMING_SNAKE_CASE="relu" ,					__SCREAMING_SNAKE_CASE=256 ,					__SCREAMING_SNAKE_CASE=0.1 ,					__SCREAMING_SNAKE_CASE=0.0 ,					__SCREAMING_SNAKE_CASE=0.0 ,					__SCREAMING_SNAKE_CASE=0.02 ,					__SCREAMING_SNAKE_CASE=1.0 ,					__SCREAMING_SNAKE_CASE=False ,					__SCREAMING_SNAKE_CASE="sine" ,					__SCREAMING_SNAKE_CASE="resnet50" ,					__SCREAMING_SNAKE_CASE=True ,					__SCREAMING_SNAKE_CASE=False ,					__SCREAMING_SNAKE_CASE=2 ,					__SCREAMING_SNAKE_CASE=5 ,					__SCREAMING_SNAKE_CASE=2 ,					__SCREAMING_SNAKE_CASE=1 ,					__SCREAMING_SNAKE_CASE=1 ,					__SCREAMING_SNAKE_CASE=2 ,					__SCREAMING_SNAKE_CASE=5 ,					__SCREAMING_SNAKE_CASE=2 ,					__SCREAMING_SNAKE_CASE=0.25 ,					**__SCREAMING_SNAKE_CASE ,					):




              """simple docstring"""




              if backbone_config is not None and use_timm_backbone:
                     raise ValueError('''You can\'t specify both `backbone_config` and `use_timm_backbone`.'''						)

              if not use_timm_backbone:
                     if backbone_config is None:
                            logger.info('''`backbone_config` is `None`. Initializing the config with the default `ResNet` backbone.'''						)
                            UpperCamelCase    :	str   	=		CONFIG_MAPPING['''resnet'''](out_features=['''stage4''']						)
                     elif isinstance(__SCREAMING_SNAKE_CASE ,					__SCREAMING_SNAKE_CASE						):
                            UpperCamelCase    :	Tuple   	=		backbone_config.get('''model_type'''						)
                            UpperCamelCase    :	Optional[Any]   	=		CONFIG_MAPPING[backbone_model_type]
                            UpperCamelCase    :	Any   	=		config_class.from_dict(__SCREAMING_SNAKE_CASE						)

              UpperCamelCase    :	List[str]   	=		use_timm_backbone
              UpperCamelCase    :	int   	=		backbone_config
              UpperCamelCase    :	Any   	=		num_channels
              UpperCamelCase    :	Optional[Any]   	=		num_queries
              UpperCamelCase    :	Tuple   	=		d_model
              UpperCamelCase    :	Optional[Any]   	=		encoder_ffn_dim
              UpperCamelCase    :	Optional[int]   	=		encoder_layers
              UpperCamelCase    :	Union[str, Any]   	=		encoder_attention_heads
              UpperCamelCase    :	Optional[Any]   	=		decoder_ffn_dim
              UpperCamelCase    :	Optional[int]   	=		decoder_layers
              UpperCamelCase    :	Optional[Any]   	=		decoder_attention_heads
              UpperCamelCase    :	Any   	=		dropout
              UpperCamelCase    :	List[Any]   	=		attention_dropout
              UpperCamelCase    :	List[Any]   	=		activation_dropout
              UpperCamelCase    :	List[str]   	=		activation_function
              UpperCamelCase    :	Optional[int]   	=		init_std
              UpperCamelCase    :	Optional[Any]   	=		init_xavier_std
              UpperCamelCase    :	Union[str, Any]   	=		encoder_layerdrop
              UpperCamelCase    :	Optional[Any]   	=		decoder_layerdrop
              UpperCamelCase    :	Tuple   	=		encoder_layers
              UpperCamelCase    :	Optional[Any]   	=		auxiliary_loss
              UpperCamelCase    :	Union[str, Any]   	=		position_embedding_type
              UpperCamelCase    :	Optional[int]   	=		backbone
              UpperCamelCase    :	Dict   	=		use_pretrained_backbone
              UpperCamelCase    :	Tuple   	=		dilation
              # Hungarian matcher
              UpperCamelCase    :	Union[str, Any]   	=		class_cost
              UpperCamelCase    :	List[Any]   	=		bbox_cost
              UpperCamelCase    :	Optional[Any]   	=		giou_cost
              # Loss coefficients
              UpperCamelCase    :	Optional[Any]   	=		mask_loss_coefficient
              UpperCamelCase    :	Optional[int]   	=		dice_loss_coefficient
              UpperCamelCase    :	Optional[Any]   	=		cls_loss_coefficient
              UpperCamelCase    :	Optional[int]   	=		bbox_loss_coefficient
              UpperCamelCase    :	Optional[int]   	=		giou_loss_coefficient
              UpperCamelCase    :	Optional[int]   	=		focal_alpha
              super().__init__(is_encoder_decoder=__SCREAMING_SNAKE_CASE ,					**__SCREAMING_SNAKE_CASE						)






       @property
       def  _lowercase   (     self						):




              """simple docstring"""




              return self.encoder_attention_heads






       @property
       def  _lowercase   (     self						):




              """simple docstring"""




              return self.d_model






       def  _lowercase   (     self						):




              """simple docstring"""




              UpperCamelCase    :	Union[str, Any]   	=		copy.deepcopy(self.__dict__						)
              if self.backbone_config is not None:
                     UpperCamelCase    :	List[Any]   	=		self.backbone_config.to_dict()
              UpperCamelCase    :	List[Any]   	=		self.__class__.model_type
              return output




class    UpperCAmelCase_	(							_a):
       '''simple docstring'''
       __UpperCamelCase      :     Dict							=					version.parse("1.11")






       @property
       def  _lowercase   (     self						):




              """simple docstring"""




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






       @property
       def  _lowercase   (     self						):




              """simple docstring"""




              return 1e-5






       @property
       def  _lowercase   (     self						):




              """simple docstring"""




              return 12

