




'''simple docstring'''





import copy

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


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

a		:	Optional[Any]       =      {
    """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       (	__A       ):



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







      '''simple docstring'''


      super().__init__(**lowerCamelCase__ )
      _a				:							Optional[int]							       =      hidden_size
      _a				:							Tuple							       =      image_size
      _a				:							str							       =      patch_size
      _a				:							Dict							       =      image_size // patch_size
      _a				:							List[Any]							       =      mask_input_channels
      _a				:							Tuple							       =      num_point_embeddings
      _a				:							Dict							       =      hidden_act
      _a				:							Optional[Any]							       =      layer_norm_eps






class      UpperCamelCase       (	__A       ):



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







      '''simple docstring'''


      super().__init__(**lowerCamelCase__ )
      _a				:							Tuple							       =      hidden_size
      _a				:							Tuple							       =      hidden_act
      _a				:							Optional[int]							       =      mlp_dim
      _a				:							Dict							       =      num_hidden_layers
      _a				:							Any							       =      num_attention_heads
      _a				:							Optional[Any]							       =      attention_downsample_rate
      _a				:							List[Any]							       =      num_multimask_outputs
      _a				:							List[Any]							       =      iou_head_depth
      _a				:							Dict							       =      iou_head_hidden_dim
      _a				:							Optional[int]							       =      layer_norm_eps






class      UpperCamelCase       (	__A       ):



  def __init__(			self		,     __lowerCAmelCase=768		,     __lowerCAmelCase=256		,     __lowerCAmelCase=12		,     __lowerCAmelCase=12		,     __lowerCAmelCase=3		,     __lowerCAmelCase=1024		,     __lowerCAmelCase=16		,     __lowerCAmelCase="gelu"		,     __lowerCAmelCase=1e-06		,     __lowerCAmelCase=0.0		,     __lowerCAmelCase=1e-10		,     __lowerCAmelCase=True		,     __lowerCAmelCase=4.0		,     __lowerCAmelCase=True		,     __lowerCAmelCase=True		,     __lowerCAmelCase=14		,     __lowerCAmelCase=[2, 5, 8, 11]		,     __lowerCAmelCase=128		,     __lowerCAmelCase=None		,     **__lowerCAmelCase		,     ):







      '''simple docstring'''


      super().__init__(**lowerCamelCase__ )

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






class      UpperCamelCase       (	__A       ):
  a     :Optional[int]          =					"""sam"""
  a     :str          =					True



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







      '''simple docstring'''


      super().__init__(**lowerCamelCase__ )
      _a				:							Union[str, Any]							       =      vision_config if vision_config is not None else {}
      _a				:							Tuple							       =      prompt_encoder_config if prompt_encoder_config is not None else {}
      _a				:							List[Any]							       =      mask_decoder_config if mask_decoder_config is not None else {}

      if isinstance(lowerCamelCase__		,     lowerCamelCase__ ):
          _a				:							Any							       =      vision_config.to_dict()
      if isinstance(lowerCamelCase__		,     lowerCamelCase__ ):
          _a				:							Optional[int]							       =      prompt_encoder_config.to_dict()
      if isinstance(lowerCamelCase__		,     lowerCamelCase__ ):
          _a				:							Optional[Any]							       =      mask_decoder_config.to_dict()

      _a				:							Union[str, Any]							       =      SamVisionConfig(**lowerCamelCase__ )
      _a				:							Dict							       =      SamPromptEncoderConfig(**lowerCamelCase__ )
      _a				:							List[str]							       =      SamMaskDecoderConfig(**lowerCamelCase__ )
      _a				:							Tuple							       =      initializer_range



  def     a_							(			self ):







      '''simple docstring'''


      _a				:							Dict							       =      copy.deepcopy(self.__dict__ )
      _a				:							int							       =      self.vision_config.to_dict()
      _a				:							Tuple							       =      self.prompt_encoder_config.to_dict()
      _a				:							Optional[int]							       =      self.mask_decoder_config.to_dict()
      _a				:							List[str]							       =      self.__class__.model_type
      return output








'''simple docstring'''
import numpy as np
def 							snake_case_    (  a__						:      Tuple     ):



    """simple docstring"""




    __lowercase							,__lowercase     							=		a.shape
    __lowercase     							=		min(a__       ,a__     )
    __lowercase     							=		np.eye(a__     )
    __lowercase     							=		a.copy()

    for k in range(t - 1     ):
        # select a column of modified matrix A':
        __lowercase     							=		r[k:, [k]]
        # construct first basis vector
        __lowercase     							=		np.zeros_like(a__     )
        __lowercase     							=		1.0
        # determine scaling factor
        __lowercase     							=		np.linalg.norm(a__     )
        # construct vector v for Householder reflection
        __lowercase     							=		x + np.sign(x[0]     ) * alpha * ea
        v /= np.linalg.norm(a__     )

        # construct the Householder matrix
        __lowercase     							=		np.eye(m - k     ) - 2.0 * v @ v.T
        # pad with ones and zeros as necessary
        __lowercase     							=		np.block([[np.eye(a__     ), np.zeros((k, m - k)     )], [np.zeros((m - k, k)     ), q_k]]     )

        __lowercase     							=		q @ q_k.T
        __lowercase     							=		q_k @ r

    return q, r


if __name__ == "__main__":
  import doctest

  doctest.testmod()




