
'''simple docstring'''







import copy

from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ..auto import CONFIG_MAPPING


_lowercase			:  List[Any]   							=	logging.get_logger(__name__)

_lowercase			:  Optional[int]   							=	{
    "SenseTime/deformable-detr": "https://huggingface.co/sensetime/deformable-detr/resolve/main/config.json",
    # See all Deformable DETR models at https://huggingface.co/models?filter=deformable-detr
}






class 			lowerCAmelCase__       (  lowerCamelCase_					):






					"""simple docstring"""




					lowerCAmelCase_					       =					'''deformable_detr'''
					lowerCAmelCase_					       =					{
					    '''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=3_00    ,							__SCREAMING_SNAKE_CASE=10_24    ,							__SCREAMING_SNAKE_CASE=6    ,							__SCREAMING_SNAKE_CASE=10_24    ,							__SCREAMING_SNAKE_CASE=8    ,							__SCREAMING_SNAKE_CASE=6    ,							__SCREAMING_SNAKE_CASE=10_24    ,							__SCREAMING_SNAKE_CASE=8    ,							__SCREAMING_SNAKE_CASE=0.0    ,							__SCREAMING_SNAKE_CASE=True    ,							__SCREAMING_SNAKE_CASE="relu"    ,							__SCREAMING_SNAKE_CASE=2_56    ,							__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=True    ,							__SCREAMING_SNAKE_CASE=False    ,							__SCREAMING_SNAKE_CASE="sine"    ,							__SCREAMING_SNAKE_CASE="resnet50"    ,							__SCREAMING_SNAKE_CASE=True    ,							__SCREAMING_SNAKE_CASE=False    ,							__SCREAMING_SNAKE_CASE=4    ,							__SCREAMING_SNAKE_CASE=4    ,							__SCREAMING_SNAKE_CASE=4    ,							__SCREAMING_SNAKE_CASE=False    ,							__SCREAMING_SNAKE_CASE=3_00    ,							__SCREAMING_SNAKE_CASE=False    ,							__SCREAMING_SNAKE_CASE=1    ,							__SCREAMING_SNAKE_CASE=5    ,							__SCREAMING_SNAKE_CASE=2    ,							__SCREAMING_SNAKE_CASE=1    ,							__SCREAMING_SNAKE_CASE=1    ,							__SCREAMING_SNAKE_CASE=5    ,							__SCREAMING_SNAKE_CASE=2    ,							__SCREAMING_SNAKE_CASE=0.1    ,							__SCREAMING_SNAKE_CASE=0.25    ,							__SCREAMING_SNAKE_CASE=False    ,							**__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.'''		)
																							lowercase_     :					str													=	CONFIG_MAPPING['''resnet'''](out_features=['''stage4''']		)
																	elif isinstance(__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE		):
																							lowercase_     :					int													=	backbone_config.get('''model_type'''		)
																							lowercase_     :					Any													=	CONFIG_MAPPING[backbone_model_type]
																							lowercase_     :					Union[str, Any]													=	config_class.from_dict(__SCREAMING_SNAKE_CASE		)
											lowercase_     :					List[str]													=	use_timm_backbone
											lowercase_     :					Optional[int]													=	backbone_config
											lowercase_     :					List[Any]													=	num_channels
											lowercase_     :					Optional[int]													=	num_queries
											lowercase_     :					Any													=	max_position_embeddings
											lowercase_     :					int													=	d_model
											lowercase_     :					str													=	encoder_ffn_dim
											lowercase_     :					Tuple													=	encoder_layers
											lowercase_     :					Optional[Any]													=	encoder_attention_heads
											lowercase_     :					List[Any]													=	decoder_ffn_dim
											lowercase_     :					Any													=	decoder_layers
											lowercase_     :					List[str]													=	decoder_attention_heads
											lowercase_     :					Tuple													=	dropout
											lowercase_     :					Any													=	attention_dropout
											lowercase_     :					Optional[int]													=	activation_dropout
											lowercase_     :					Optional[int]													=	activation_function
											lowercase_     :					Optional[int]													=	init_std
											lowercase_     :					List[Any]													=	init_xavier_std
											lowercase_     :					Any													=	encoder_layerdrop
											lowercase_     :					Dict													=	auxiliary_loss
											lowercase_     :					Dict													=	position_embedding_type
											lowercase_     :					int													=	backbone
											lowercase_     :					Union[str, Any]													=	use_pretrained_backbone
											lowercase_     :					str													=	dilation
											# deformable attributes
											lowercase_     :					Tuple													=	num_feature_levels
											lowercase_     :					int													=	encoder_n_points
											lowercase_     :					int													=	decoder_n_points
											lowercase_     :					Any													=	two_stage
											lowercase_     :					Optional[int]													=	two_stage_num_proposals
											lowercase_     :					Optional[Any]													=	with_box_refine
											if two_stage is True and with_box_refine is False:
																	raise ValueError('''If two_stage is True, with_box_refine must be True.'''		)
											# Hungarian matcher
											lowercase_     :					Tuple													=	class_cost
											lowercase_     :					int													=	bbox_cost
											lowercase_     :					Dict													=	giou_cost
											# Loss coefficients
											lowercase_     :					Tuple													=	mask_loss_coefficient
											lowercase_     :					Optional[int]													=	dice_loss_coefficient
											lowercase_     :					List[str]													=	bbox_loss_coefficient
											lowercase_     :					Dict													=	giou_loss_coefficient
											lowercase_     :					Optional[int]													=	eos_coefficient
											lowercase_     :					Dict													=	focal_alpha
											lowercase_     :					int													=	disable_custom_kernels
											super().__init__(is_encoder_decoder=__SCREAMING_SNAKE_CASE    ,							**__SCREAMING_SNAKE_CASE		)






					@property
					def      _snake_case   (       self		):


											"""simple docstring"""





											return self.encoder_attention_heads






					@property
					def      _snake_case   (       self		):


											"""simple docstring"""





											return self.d_model






					def      _snake_case   (       self		):


											"""simple docstring"""





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





'''simple docstring'''







from __future__ import annotations






class 			lowerCAmelCase__       :






					def __init__(       self    ,							__SCREAMING_SNAKE_CASE = 0		):


											"""simple docstring"""





											lowercase_     :					Any													=	key






					def      _snake_case   (       self    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE		):


											"""simple docstring"""





											assert isinstance(__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE		) and isinstance(__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE		)

											lowercase_     :					List[str]													=	key or self.__key or 1

											# make sure key is an appropriate size
											key %= 2_55

											return [chr(ord(__SCREAMING_SNAKE_CASE		) ^ key		) for ch in content]






					def      _snake_case   (       self    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE		):


											"""simple docstring"""





											assert isinstance(__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE		) and isinstance(__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE		)

											lowercase_     :					Optional[int]													=	key or self.__key or 1

											# make sure key is an appropriate size
											key %= 2_55

											return [chr(ord(__SCREAMING_SNAKE_CASE		) ^ key		) for ch in content]






					def      _snake_case   (       self    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE = 0		):


											"""simple docstring"""





											assert isinstance(__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE		) and isinstance(__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE		)

											lowercase_     :					List[Any]													=	key or self.__key or 1

											# make sure key can be any size
											while key > 2_55:
																	key -= 2_55

											# This will be returned
											lowercase_     :					str													=	''''''

											for ch in content:
																	ans += chr(ord(__SCREAMING_SNAKE_CASE		) ^ key		)

											return ans






					def      _snake_case   (       self    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE = 0		):


											"""simple docstring"""





											assert isinstance(__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE		) and isinstance(__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE		)

											lowercase_     :					Any													=	key or self.__key or 1

											# make sure key can be any size
											while key > 2_55:
																	key -= 2_55

											# This will be returned
											lowercase_     :					Dict													=	''''''

											for ch in content:
																	ans += chr(ord(__SCREAMING_SNAKE_CASE		) ^ key		)

											return ans






					def      _snake_case   (       self    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE = 0		):


											"""simple docstring"""





											assert isinstance(__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE		) and isinstance(__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE		)

											try:
																	with open(__SCREAMING_SNAKE_CASE		) as fin, open('''encrypt.out'''    ,							'''w+'''		) as fout:
																							# actual encrypt-process
																							for line in fin:
																													fout.write(self.encrypt_string(__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE		)		)

											except OSError:
																	return False

											return True






					def      _snake_case   (       self    ,							__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE		):


											"""simple docstring"""





											assert isinstance(__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE		) and isinstance(__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE		)

											try:
																	with open(__SCREAMING_SNAKE_CASE		) as fin, open('''decrypt.out'''    ,							'''w+'''		) as fout:
																							# actual encrypt-process
																							for line in fin:
																													fout.write(self.decrypt_string(__SCREAMING_SNAKE_CASE    ,							__SCREAMING_SNAKE_CASE		)		)

											except OSError:
																	return False

											return True


# Tests
# crypt = XORCipher()
# key = 67

# # test encrypt
# print(crypt.encrypt("hallo welt",key))
# # test decrypt
# print(crypt.decrypt(crypt.encrypt("hallo welt",key), key))

# # test encrypt_string
# print(crypt.encrypt_string("hallo welt",key))

# # test decrypt_string
# print(crypt.decrypt_string(crypt.encrypt_string("hallo welt",key),key))

# if (crypt.encrypt_file("test.txt",key)):
#       print("encrypt successful")
# else:
#       print("encrypt unsuccessful")

# if (crypt.decrypt_file("encrypt.out",key)):
#       print("decrypt successful")
# else:
#       print("decrypt unsuccessful")



