code: def get_3d_sincos_pos_embed(
      embed_dim, grid_size, t_size, cls_token=False
  ):
      """
      grid_size: int of the grid height and width
      t_size: int of the temporal size
      return:
      pos_embed: [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)  # here w goes first
      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
      )
  
      # concate: [T, H, W] order
      pos_embed_temporal = pos_embed_temporal[:, np.newaxis, :]
      pos_embed_temporal = np.repeat(
          pos_embed_temporal, grid_size**2, axis=1
      )  # [T, H*W, D // 4]
      pos_embed_spatial = pos_embed_spatial[np.newaxis, :, :]
      pos_embed_spatial = np.repeat(
          pos_embed_spatial, t_size, axis=0
      )  # [T, H*W, D // 4 * 3]
  
      pos_embed = np.concatenate(
          [pos_embed_temporal, pos_embed_spatial], axis=-1
      )
      pos_embed = pos_embed.reshape([-1, embed_dim])  # [T*H*W, D]
  
      if cls_token:
          pos_embed = np.concatenate(
              [np.zeros([1, embed_dim]), pos_embed], axis=0
          )
      return pos_embed
  
file_path: SlowFast/slowfast/models/utils.py
imports: import numpy
  import torch
  import slowfast.utils.logging
label_desc: Use image node_id 4 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