code: def _build_sam(
      encoder_embed_dim: int,
      encoder_depth: int,
      encoder_num_heads: int,
      encoder_global_attn_indexes: tuple[int, ...],
  ) -> Sam:
      prompt_embed_dim = 256
      image_size = 1024
      vit_patch_size = 16
      image_embedding_size = image_size // vit_patch_size
  
      return Sam(
          image_encoder=ImageEncoderViT(
              depth=encoder_depth,
              embed_dim=encoder_embed_dim,
              img_size=image_size,
              mlp_ratio=4,
              norm_layer=LayerNorm,
              num_heads=encoder_num_heads,
              patch_size=vit_patch_size,
              qkv_bias=True,
              use_rel_pos=True,
              global_attn_indexes=encoder_global_attn_indexes,
              window_size=14,
              out_chans=prompt_embed_dim,
          ),
          prompt_encoder=PromptEncoder(
              embed_dim=prompt_embed_dim,
              image_embedding_size=(
                  image_embedding_size,
                  image_embedding_size,
              ),
              input_image_size=(image_size, image_size),
              mask_in_chans=16,
          ),
          mask_decoder=MaskDecoder(
              num_multimask_outputs=3,
              transformer=TwoWayTransformer(
                  depth=2,
                  embedding_dim=prompt_embed_dim,
                  mlp_dim=2048,
                  num_heads=8,
              ),
              transformer_dim=prompt_embed_dim,
              iou_head_depth=3,
              iou_head_hidden_dim=256,
          ),
          #     pixel_mean=[123.675, 116.28, 103.53],
          #     pixel_std=[58.395, 57.12, 57.375],
      )
  
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 for calling a global function with example usage: _build_sam(encoder_embed_dim, encoder_depth, encoder_num_heads, encoder_global_attn_indexes) and returns: Sam