code: def get_2d_sincos_pos_embed(
      embed_dim: int, grid_size: int, cls_token: bool = False
  ) -> torch.Tensor:
      """
      Get 2D sine-cosine positional embedding.
      Args:
          grid_size: int of the grid height and width
          cls_token: bool, whether to contain CLS token
      Returns:
          (torch.Tensor): [grid_size*grid_size, embed_dim] or [1+grid_size*grid_size, embed_dim] (w/ or w/o cls_token)
      """
      grid_h = np.arange(grid_size, dtype=np.float32)
      grid_w = np.arange(grid_size, dtype=np.float32)
      grid = np.meshgrid(grid_w, grid_h)
      grid = np.stack(grid, axis=0)
  
      grid = grid.reshape([2, 1, grid_size, grid_size])
      pos_embed = get_2d_sincos_pos_embed_from_grid(embed_dim, grid)
      if cls_token:
          pos_embed = np.concatenate(
              [np.zeros([1, embed_dim]), pos_embed], axis=0
          )
      return pos_embed
  
file_path: pytorchvideo/pytorchvideo/layers/positional_encoding.py
imports: import math
  from typing import Tuple
  import numpy
  import torch
  from torch import nn
label_desc: Use image node_id 2 for calling a global function with example usage: get_2d_sincos_pos_embed(embed_dim, grid_size, cls_token) and returns: pos_embed