code: def get_3d_sincos_pos_embed(
      embed_dim: int,
      grid_size: int,
      t_size: int,
      cls_token: bool = False,
  ) -> torch.Tensor:
      """
      Get 3D sine-cosine positional embedding.
      Args:
          grid_size: int of the grid height and width
          t_size: int of the temporal size
          cls_token: bool, whether to contain CLS token
      Returns:
          (torch.Tensor): [t_size*grid_size*grid_size, embed_dim] or [1+t_size*grid_size*grid_size, embed_dim] (w/ or w/o cls_token)
      """
      assert embed_dim % 4 == 0
      embed_dim_spatial = embed_dim // 4 * 3
      embed_dim_temporal = embed_dim // 4
  
      # spatial
      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_spatial = get_2d_sincos_pos_embed_from_grid(
          embed_dim_spatial, grid
      )
  
      # temporal
      grid_t = np.arange(t_size, dtype=np.float32)
      pos_embed_temporal = get_1d_sincos_pos_embed_from_grid(
          embed_dim_temporal, grid_t
      )
  
      pos_embed_temporal = pos_embed_temporal[:, np.newaxis, :]
      pos_embed_temporal = np.repeat(
          pos_embed_temporal, grid_size**2, axis=1
      )
      pos_embed_spatial = pos_embed_spatial[np.newaxis, :, :]
      pos_embed_spatial = np.repeat(pos_embed_spatial, t_size, axis=0)
  
      pos_embed = np.concatenate(
          [pos_embed_temporal, pos_embed_spatial], axis=-1
      )
      pos_embed = pos_embed.reshape([-1, embed_dim])
  
      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 1 for calling a global function with example usage: get_3d_sincos_pos_embed(embed_dim, grid_size, t_size, cls_token) and returns: pos_embed