docstr: SAM predicts object masks from an image and input prompts.
  
  Args:
      image_encoder: The backbone used to encode the image into image embeddings that allow for efficient mask
                     prediction.
      prompt_encoder: Encodes various types of input prompts.
      mask_decoder: Predicts masks from the image embeddings and encoded prompts.
docstr_tok: ["SAM","predicts","object","masks","from","an","image","and","input","prompts",".","Args",":","image_encoder",":","The","backbone","used","to","encode","the","image","into","image","embeddings","that","allow","for","efficient","mask","prediction",".","prompt_encoder",":","Encodes","various","types","of","input","prompts",".","mask_decoder",":","Predicts","masks","from","the","image","embeddings","and","encoded","prompts","."]
code: def __init__(
      self,
      image_encoder: ImageEncoderViT | TinyViT,
      prompt_encoder: PromptEncoder,
      mask_decoder: MaskDecoder,
  ) -> None:
      """SAM predicts object masks from an image and input prompts.
  
      Args:
          image_encoder: The backbone used to encode the image into image embeddings that allow for efficient mask
                         prediction.
          prompt_encoder: Encodes various types of input prompts.
          mask_decoder: Predicts masks from the image embeddings and encoded prompts.
      """
  
      super().__init__()
      self.image_encoder = image_encoder
      self.prompt_encoder = prompt_encoder
      self.mask_decoder = mask_decoder
  
imports: from __future__ import annotations
  import warnings
  from dataclasses import dataclass
  from enum import Enum
  from typing import Any, Optional
  import torch
  from kornia.contrib.models import SegmentationResults
  from kornia.contrib.models.base import ModelBase
  from kornia.contrib.models.sam.architecture.common import LayerNorm
  from kornia.contrib.models.sam.architecture.image_encoder import ImageEncoderViT
  from kornia.contrib.models.sam.architecture.mask_decoder import MaskDecoder
  from kornia.contrib.models.sam.architecture.prompt_encoder import PromptEncoder
  from kornia.contrib.models.sam.architecture.transformer import TwoWayTransformer
  from kornia.contrib.models.tiny_vit import TinyViT
  from kornia.core import Tensor
  from kornia.core.check import KORNIA_CHECK, KORNIA_CHECK_SHAPE
label_desc: Use image node_id 1 to create a new Sam object from inherited base classes: ModelBase with example: obj = Sam(image_encoder, prompt_encoder, mask_decoder)