class_docstr: Position embedding with learnable embedding weights.
  
  Args:
      num_feats (int): The feature dimension for each position
          along x-axis or y-axis. The final returned dimension for
          each position is 2 times of this value.
      row_num_embed (int, optional): The dictionary size of row embeddings.
          Default 50.
      col_num_embed (int, optional): The dictionary size of col embeddings.
          Default 50.
docstr: Forward function for `LearnedPositionalEncoding`.
  
  Args:
      mask (Tensor): ByteTensor mask. Non-zero values representing
          ignored positions, while zero values means valid positions
          for this image. Shape [bs, h, w].
  
  Returns:
      pos (Tensor): Returned position embedding with shape
          [bs, num_feats*2, h, w].
docstr_tok: ["Forward","function","for","`","LearnedPositionalEncoding","`",".","Args",":","mask","(","Tensor",")",":","ByteTensor","mask",".","Non-zero","values","representing","ignored","positions",",","while","zero","values","means","valid","positions","for","this","image",".","Shape","[","bs",",","h",",","w","]",".","Returns",":","pos","(","Tensor",")",":","Returned","position","embedding","with","shape","[","bs",",","num_feats","*","2",",","h",",","w","]","."]
code: def forward(self, mask):
      """Forward function for `LearnedPositionalEncoding`.
  
      Args:
          mask (Tensor): ByteTensor mask. Non-zero values representing
              ignored positions, while zero values means valid positions
              for this image. Shape [bs, h, w].
  
      Returns:
          pos (Tensor): Returned position embedding with shape
              [bs, num_feats*2, h, w].
      """
      h, w = mask.shape[-2:]
      x = torch.arange(w, device=mask.device)
      y = torch.arange(h, device=mask.device)
      x_embed = self.col_embed(x)
      y_embed = self.row_embed(y)
      pos = (
          torch.cat(
              (
                  x_embed.unsqueeze(0).repeat(h, 1, 1),
                  y_embed.unsqueeze(1).repeat(1, w, 1),
              ),
              dim=-1,
          )
          .permute(2, 0, 1)
          .unsqueeze(0)
          .repeat(mask.shape[0], 1, 1, 1)
      )
      return pos
  
file_path: insightface/detection/scrfd/mmdet/models/utils/positional_encoding.py
imports: import math
  import torch
  import torch.nn
  from mmcv.cnn import uniform_init
  from .builder import POSITIONAL_ENCODING
label_desc: Use image node_id 3 for calling the LearnedPositionalEncoding obj's underlying member method code with example usage: obj.forward(mask) and returns: pos