docstr: Embeds different types of prompts, returning both sparse and dense
  embeddings.
  
  Arguments:
    points (tuple(torch.Tensor, torch.Tensor) or none): point coordinates
      and labels to embed.
    boxes (torch.Tensor or none): boxes to embed
    masks (torch.Tensor or none): masks to embed
  
  Returns:
    torch.Tensor: sparse embeddings for the points and boxes, with shape
      BxNx(embed_dim), where N is determined by the number of input points
      and boxes.
    torch.Tensor: dense embeddings for the masks, in the shape
      Bx(embed_dim)x(embed_H)x(embed_W)
docstr_tok: ["Embeds","different","types","of","prompts",",","returning","both","sparse","and","dense","embeddings",".","Arguments",":","points","(","tuple","(","torch.Tensor",",","torch.Tensor",")","or","none",")",":","point","coordinates","and","labels","to","embed",".","boxes","(","torch.Tensor","or","none",")",":","boxes","to","embed","masks","(","torch.Tensor","or","none",")",":","masks","to","embed","Returns",":","torch.Tensor",":","sparse","embeddings","for","the","points","and","boxes",",","with","shape","BxNx","(","embed_dim",")",",","where","N","is","determined","by","the","number","of","input","points","and","boxes",".","torch.Tensor",":","dense","embeddings","for","the","masks",",","in","the","shape","Bx","(","embed_dim",")","x","(","embed_H",")","x","(","embed_W",")"]
code: def forward(
      self,
      points: Optional[Tuple[paddle.Tensor, paddle.Tensor]],
      boxes: Optional[paddle.Tensor],
      masks: Optional[paddle.Tensor],
  ) -> Tuple[paddle.Tensor, paddle.Tensor]:
      """
      Embeds different types of prompts, returning both sparse and dense
      embeddings.
  
      Arguments:
        points (tuple(torch.Tensor, torch.Tensor) or none): point coordinates
          and labels to embed.
        boxes (torch.Tensor or none): boxes to embed
        masks (torch.Tensor or none): masks to embed
  
      Returns:
        torch.Tensor: sparse embeddings for the points and boxes, with shape
          BxNx(embed_dim), where N is determined by the number of input points
          and boxes.
        torch.Tensor: dense embeddings for the masks, in the shape
          Bx(embed_dim)x(embed_H)x(embed_W)
      """
      bs = self._get_batch_size(points, boxes, masks)
      sparse_embeddings = paddle.empty(shape=(bs, 0, self.embed_dim))
      if points is not None:
          coords, labels = points
          point_embeddings = self._embed_points(
              coords, labels, pad=boxes is None
          )
          sparse_embeddings = paddle.concat(
              x=[sparse_embeddings, point_embeddings], axis=1
          )
      if boxes is not None:
          box_embeddings = self._embed_boxes(boxes)
          sparse_embeddings = paddle.concat(
              x=[sparse_embeddings, box_embeddings], axis=1
          )
      if masks is not None:
          dense_embeddings = self._embed_masks(masks)
      else:
          """Class Method: *.reshape, not convert, please check whether it is torch.Tensor.*/Optimizer.*/nn.Module.*, and convert manually"""
          dense_embeddings = self.no_mask_embed.weight.reshape(
              [1, -1, 1, 1]
          ).expand(
              shape=[
                  bs,
                  -1,
                  self.image_embedding_size[0],
                  self.image_embedding_size[1],
              ]
          )
      return sparse_embeddings, dense_embeddings
  
file_path: PaddleSeg/contrib/SegmentAnything/segment_anything/modeling/prompt_encoder.py
imports: import paddle
  import numpy
  from typing import Any, Optional, Tuple, Type
  from common import LayerNorm2d
label_desc: Use image node_id 8 for calling the PromptEncoder obj's underlying member method code with example usage: obj.forward(points, boxes, masks) and returns: sparse_embeddings,  dense_embeddings