code: def get_1d_sincos_pos_embed_from_grid(
      embed_dim: int, pos: np.ndarray
  ) -> torch.Tensor:
      """
      Get 1D sine-cosine positional embedding.
      Args:
          embed_dim: output dimension for each position
          pos: a list of positions to be encoded: size (M,)
      Returns:
          (torch.Tensor): tensor of shape (M, D)
      """
      assert embed_dim % 2 == 0
      omega = np.arange(embed_dim // 2, dtype=float)
      omega /= embed_dim / 2.0
      omega = 1.0 / 10000**omega
  
      pos = pos.reshape(-1)
      out = np.einsum("m,d->md", pos, omega)
  
      emb_sin = np.sin(out)
      emb_cos = np.cos(out)
  
      emb = np.concatenate([emb_sin, emb_cos], axis=1)
      return emb
  
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 4 for calling a global function with example usage: get_1d_sincos_pos_embed_from_grid(embed_dim, pos) and returns: emb