





import copy

from ...configuration_utils import PretrainedConfig
from ...utils import logging


_lowerCamelCase       =	logging.get_logger(__name__)

_lowerCamelCase       =	{
    'facebook/sam-vit-huge': 'https://huggingface.co/facebook/sam-vit-huge/resolve/main/config.json',
    'facebook/sam-vit-large': 'https://huggingface.co/facebook/sam-vit-large/resolve/main/config.json',
    'facebook/sam-vit-base': 'https://huggingface.co/facebook/sam-vit-base/resolve/main/config.json',
}




class      UpperCamelCase_				(   UpperCamelCase__			):


							def __init__(							self			:int							, __A			:Dict=256							, __A			:str=1024							, __A			:Optional[Any]=16							, __A			:Any=16							, __A			:Optional[int]=4							, __A			:Any="gelu"							, __A			:Union[str, Any]=1E-6							, **__A			:int							, )      ->      Tuple:



									"""simple docstring"""



									super().__init__(**__A						)
									SCREAMING_SNAKE_CASE__								=					hidden_size
									SCREAMING_SNAKE_CASE__								=					image_size
									SCREAMING_SNAKE_CASE__								=					patch_size
									SCREAMING_SNAKE_CASE__								=					image_size // patch_size
									SCREAMING_SNAKE_CASE__								=					mask_input_channels
									SCREAMING_SNAKE_CASE__								=					num_point_embeddings
									SCREAMING_SNAKE_CASE__								=					hidden_act
									SCREAMING_SNAKE_CASE__								=					layer_norm_eps




class      UpperCamelCase_				(   UpperCamelCase__			):


							def __init__(							self			:Union[str, Any]							, __A			:Optional[int]=256							, __A			:Optional[int]="relu"							, __A			:Any=2048							, __A			:List[Any]=2							, __A			:Dict=8							, __A			:Optional[Any]=2							, __A			:Tuple=3							, __A			:int=3							, __A			:str=256							, __A			:str=1E-6							, **__A			:Tuple							, )      ->      int:



									"""simple docstring"""



									super().__init__(**__A						)
									SCREAMING_SNAKE_CASE__								=					hidden_size
									SCREAMING_SNAKE_CASE__								=					hidden_act
									SCREAMING_SNAKE_CASE__								=					mlp_dim
									SCREAMING_SNAKE_CASE__								=					num_hidden_layers
									SCREAMING_SNAKE_CASE__								=					num_attention_heads
									SCREAMING_SNAKE_CASE__								=					attention_downsample_rate
									SCREAMING_SNAKE_CASE__								=					num_multimask_outputs
									SCREAMING_SNAKE_CASE__								=					iou_head_depth
									SCREAMING_SNAKE_CASE__								=					iou_head_hidden_dim
									SCREAMING_SNAKE_CASE__								=					layer_norm_eps




class      UpperCamelCase_				(   UpperCamelCase__			):


							def __init__(							self			:List[Any]							, __A			:List[Any]=768							, __A			:Dict=256							, __A			:Optional[int]=12							, __A			:Optional[int]=12							, __A			:str=3							, __A			:Union[str, Any]=1024							, __A			:List[str]=16							, __A			:Dict="gelu"							, __A			:Dict=1E-06							, __A			:List[str]=0.0							, __A			:Dict=1E-10							, __A			:List[Any]=True							, __A			:Tuple=4.0							, __A			:int=True							, __A			:List[str]=True							, __A			:Optional[int]=14							, __A			:int=[2, 5, 8, 11]							, __A			:Tuple=128							, __A			:Optional[int]=None							, **__A			:int							, )      ->      Any:



									"""simple docstring"""



									super().__init__(**__A						)

									SCREAMING_SNAKE_CASE__								=					hidden_size
									SCREAMING_SNAKE_CASE__								=					output_channels
									SCREAMING_SNAKE_CASE__								=					num_hidden_layers
									SCREAMING_SNAKE_CASE__								=					num_attention_heads
									SCREAMING_SNAKE_CASE__								=					num_channels
									SCREAMING_SNAKE_CASE__								=					image_size
									SCREAMING_SNAKE_CASE__								=					patch_size
									SCREAMING_SNAKE_CASE__								=					hidden_act
									SCREAMING_SNAKE_CASE__								=					layer_norm_eps
									SCREAMING_SNAKE_CASE__								=					attention_dropout
									SCREAMING_SNAKE_CASE__								=					initializer_range
									SCREAMING_SNAKE_CASE__								=					qkv_bias
									SCREAMING_SNAKE_CASE__								=					mlp_ratio
									SCREAMING_SNAKE_CASE__								=					use_abs_pos
									SCREAMING_SNAKE_CASE__								=					use_rel_pos
									SCREAMING_SNAKE_CASE__								=					window_size
									SCREAMING_SNAKE_CASE__								=					global_attn_indexes
									SCREAMING_SNAKE_CASE__								=					num_pos_feats
									SCREAMING_SNAKE_CASE__								=					int(hidden_size * mlp_ratio						) if mlp_dim is None else mlp_dim




class      UpperCamelCase_				(   UpperCamelCase__			):
							lowerCamelCase_							=    "sam"
							lowerCamelCase_							=    True


							def __init__(							self			:Union[str, Any]							, __A			:Union[str, Any]=None							, __A			:str=None							, __A			:Dict=None							, __A			:str=0.0_2							, **__A			:List[str]							, )      ->      List[Any]:



									"""simple docstring"""



									super().__init__(**__A						)
									SCREAMING_SNAKE_CASE__								=					vision_config if vision_config is not None else {}
									SCREAMING_SNAKE_CASE__								=					prompt_encoder_config if prompt_encoder_config is not None else {}
									SCREAMING_SNAKE_CASE__								=					mask_decoder_config if mask_decoder_config is not None else {}

									if isinstance(__A							, __A						):
											SCREAMING_SNAKE_CASE__								=					vision_config.to_dict()
									if isinstance(__A							, __A						):
											SCREAMING_SNAKE_CASE__								=					prompt_encoder_config.to_dict()
									if isinstance(__A							, __A						):
											SCREAMING_SNAKE_CASE__								=					mask_decoder_config.to_dict()

									SCREAMING_SNAKE_CASE__								=					SamVisionConfig(**__A						)
									SCREAMING_SNAKE_CASE__								=					SamPromptEncoderConfig(**__A						)
									SCREAMING_SNAKE_CASE__								=					SamMaskDecoderConfig(**__A						)
									SCREAMING_SNAKE_CASE__								=					initializer_range


							def    _snake_case     (							self			:str						)      ->      Dict:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=					copy.deepcopy(self.__dict__						)
									SCREAMING_SNAKE_CASE__								=					self.vision_config.to_dict()
									SCREAMING_SNAKE_CASE__								=					self.prompt_encoder_config.to_dict()
									SCREAMING_SNAKE_CASE__								=					self.mask_decoder_config.to_dict()
									SCREAMING_SNAKE_CASE__								=					self.__class__.model_type
									return output






from datetime import date

import requests

_lowerCamelCase       =	'https://api.carbonintensity.org.uk/intensity'






def  SCREAMING_SNAKE_CASE__							(				):
		SCREAMING_SNAKE_CASE__								=					requests.get(UpperCamelCase__			).json()["""data"""][0]
		return last_half_hour["intensity"]["actual"]






def  SCREAMING_SNAKE_CASE__							(				UpperCamelCase__:							Dict    ,      UpperCamelCase__:							Optional[int]			):
		return requests.get(f'''{BASE_URL}/{start}/{end}'''			).json()["data"]


if __name__ == "__main__":
	for entry in fetch_from_to(start=date(2020, 10, 1), end=date(2020, 10, 3)):
		print('from {from} to {to}: {intensity[actual]}'.format(**entry))
	print(F'''{fetch_last_half_hour() = }''')