
"""simple docstring"""





import copy

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


_a	 =							logging.get_logger(__name__)

_a	 =							{
    '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 A_			(lowercase__   ):




  '''simple docstring'''







  def __init__(	self       ,     lowercase_=256       ,     lowercase_=1024       ,     lowercase_=16       ,     lowercase_=16       ,     lowercase_=4       ,     lowercase_="gelu"       ,     lowercase_=1E-6       ,     **lowercase_       ,     ):

     """simple docstring"""
     super().__init__(**lowercase_						)
     UpperCAmelCase_      :      Dict      =					hidden_size
     UpperCAmelCase_      :      List[Any]      =					image_size
     UpperCAmelCase_      :      Tuple      =					patch_size
     UpperCAmelCase_      :      Optional[Any]      =					image_size // patch_size
     UpperCAmelCase_      :      Union[str, Any]      =					mask_input_channels
     UpperCAmelCase_      :      int      =					num_point_embeddings
     UpperCAmelCase_      :      Optional[Any]      =					hidden_act
     UpperCAmelCase_      :      List[str]      =					layer_norm_eps




class A_			(lowercase__   ):




  '''simple docstring'''







  def __init__(	self       ,     lowercase_=256       ,     lowercase_="relu"       ,     lowercase_=2048       ,     lowercase_=2       ,     lowercase_=8       ,     lowercase_=2       ,     lowercase_=3       ,     lowercase_=3       ,     lowercase_=256       ,     lowercase_=1E-6       ,     **lowercase_       ,     ):

     """simple docstring"""
     super().__init__(**lowercase_						)
     UpperCAmelCase_      :      Tuple      =					hidden_size
     UpperCAmelCase_      :      Union[str, Any]      =					hidden_act
     UpperCAmelCase_      :      Any      =					mlp_dim
     UpperCAmelCase_      :      Optional[Any]      =					num_hidden_layers
     UpperCAmelCase_      :      Dict      =					num_attention_heads
     UpperCAmelCase_      :      List[Any]      =					attention_downsample_rate
     UpperCAmelCase_      :      List[str]      =					num_multimask_outputs
     UpperCAmelCase_      :      Any      =					iou_head_depth
     UpperCAmelCase_      :      List[str]      =					iou_head_hidden_dim
     UpperCAmelCase_      :      Any      =					layer_norm_eps




class A_			(lowercase__   ):




  '''simple docstring'''







  def __init__(	self       ,     lowercase_=768       ,     lowercase_=256       ,     lowercase_=12       ,     lowercase_=12       ,     lowercase_=3       ,     lowercase_=1024       ,     lowercase_=16       ,     lowercase_="gelu"       ,     lowercase_=1E-0_6       ,     lowercase_=0.0       ,     lowercase_=1E-1_0       ,     lowercase_=True       ,     lowercase_=4.0       ,     lowercase_=True       ,     lowercase_=True       ,     lowercase_=14       ,     lowercase_=[2, 5, 8, 11]       ,     lowercase_=128       ,     lowercase_=None       ,     **lowercase_       ,     ):

     """simple docstring"""
     super().__init__(**lowercase_						)

     UpperCAmelCase_      :      List[str]      =					hidden_size
     UpperCAmelCase_      :      Any      =					output_channels
     UpperCAmelCase_      :      Optional[int]      =					num_hidden_layers
     UpperCAmelCase_      :      Union[str, Any]      =					num_attention_heads
     UpperCAmelCase_      :      str      =					num_channels
     UpperCAmelCase_      :      Optional[int]      =					image_size
     UpperCAmelCase_      :      Optional[int]      =					patch_size
     UpperCAmelCase_      :      Optional[Any]      =					hidden_act
     UpperCAmelCase_      :      List[Any]      =					layer_norm_eps
     UpperCAmelCase_      :      Dict      =					attention_dropout
     UpperCAmelCase_      :      Optional[int]      =					initializer_range
     UpperCAmelCase_      :      Dict      =					qkv_bias
     UpperCAmelCase_      :      int      =					mlp_ratio
     UpperCAmelCase_      :      List[Any]      =					use_abs_pos
     UpperCAmelCase_      :      List[str]      =					use_rel_pos
     UpperCAmelCase_      :      int      =					window_size
     UpperCAmelCase_      :      Optional[int]      =					global_attn_indexes
     UpperCAmelCase_      :      Union[str, Any]      =					num_pos_feats
     UpperCAmelCase_      :      str      =					int(hidden_size * mlp_ratio						) if mlp_dim is None else mlp_dim




class A_			(lowercase__   ):




  '''simple docstring'''
  SCREAMING_SNAKE_CASE__    :		Tuple						  =	"""sam"""
  SCREAMING_SNAKE_CASE__    :		Optional[Any]						  =	True







  def __init__(	self       ,     lowercase_=None       ,     lowercase_=None       ,     lowercase_=None       ,     lowercase_=0.02       ,     **lowercase_       ,     ):

     """simple docstring"""
     super().__init__(**lowercase_						)
     UpperCAmelCase_      :      Optional[int]      =					vision_config if vision_config is not None else {}
     UpperCAmelCase_      :      Optional[int]      =					prompt_encoder_config if prompt_encoder_config is not None else {}
     UpperCAmelCase_      :      Dict      =					mask_decoder_config if mask_decoder_config is not None else {}

     if isinstance(lowercase_       ,     lowercase_						):
        UpperCAmelCase_      :      Optional[Any]      =					vision_config.to_dict()
     if isinstance(lowercase_       ,     lowercase_						):
        UpperCAmelCase_      :      Any      =					prompt_encoder_config.to_dict()
     if isinstance(lowercase_       ,     lowercase_						):
        UpperCAmelCase_      :      List[Any]      =					mask_decoder_config.to_dict()

     UpperCAmelCase_      :      Optional[int]      =					SamVisionConfig(**lowercase_						)
     UpperCAmelCase_      :      str      =					SamPromptEncoderConfig(**lowercase_						)
     UpperCAmelCase_      :      Tuple      =					SamMaskDecoderConfig(**lowercase_						)
     UpperCAmelCase_      :      Any      =					initializer_range







  def  UpperCamelCase__      (	self						):

     """simple docstring"""
     UpperCAmelCase_      :      int      =					copy.deepcopy(self.__dict__						)
     UpperCAmelCase_      :      Union[str, Any]      =					self.vision_config.to_dict()
     UpperCAmelCase_      :      List[Any]      =					self.prompt_encoder_config.to_dict()
     UpperCAmelCase_      :      Any      =					self.mask_decoder_config.to_dict()
     UpperCAmelCase_      :      int      =					self.__class__.model_type
     return output




"""simple docstring"""





from __future__ import annotations

from statistics import mean







def 			__a  (	__lowerCamelCase						):
   UpperCAmelCase_      :      Dict      =					2
   UpperCAmelCase_      :      Any      =					list(__lowerCamelCase						)
   UpperCAmelCase_      :      List[Any]      =					[0] * len(__lowerCamelCase						)
   UpperCAmelCase_      :      str      =					0
   while True:
      UpperCAmelCase_      :      int      =					True
      for i, burst_time in enumerate(__lowerCamelCase						):
         if rem_burst_times[i] > 0:
            UpperCAmelCase_      :      List[Any]      =					False
            if rem_burst_times[i] > quantum:
               t += quantum
               rem_burst_times[i] -= quantum
            else:
               t += rem_burst_times[i]
               UpperCAmelCase_      :      Optional[int]      =					t - burst_time
               UpperCAmelCase_      :      Union[str, Any]      =					0
      if done is True:
         return waiting_times







def 			__a  (	__lowerCamelCase,	__lowerCamelCase						):
   return [burst + waiting for burst, waiting in zip(__lowerCamelCase,	__lowerCamelCase						)]


if __name__ == "__main__":
    _a	 =							[3, 5, 7]
    _a	 =							calculate_waiting_times(burst_times)
    _a	 =							calculate_turn_around_times(burst_times, waiting_times)
    print('Process ID \tBurst Time \tWaiting Time \tTurnaround Time')
    for i, burst_time in enumerate(burst_times):
        print(
            f"""  {i + 1}\t\t  {burst_time}\t\t  {waiting_times[i]}\t\t  """
            f"""{turn_around_times[i]}"""
        )
    print(f"""\nAverage waiting time = {mean(waiting_times):.5f}""")
    print(f"""Average turn around time = {mean(turn_around_times):.5f}""")


