code: def get_2d_sincos_pos_embed(
      embed_dim: int, grid_size: int, cls_token: bool = False
  ) -> NDArray[np.float_]:
      """Returns 2D sin-cos embeddings. Code from [0].
  
      - [0]: https://github.com/facebookresearch/ijepa
  
      Args:
          embed_dim:
              Embedding dimension.
          grid_size:
              Grid height and width. Should usually be set to sqrt(sequence length).
          cls_token:
              If True, a positional embedding for the class token is prepended to the returned
              embeddings.
  
      Returns:
          Positional embeddings array with size (grid_size * grid_size, embed_dim) if cls_token is False.
          If cls_token is True, a (1 + grid_size * grid_size, embed_dim) array is returned.
      """
      grid_h = np.arange(grid_size, dtype=float)
      grid_w = np.arange(grid_size, dtype=float)
      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 = 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
  
imports: import math
  import warnings
  from typing import Iterable, List, Optional, Tuple, Union
  import numpy
  import torch
  import torch.distributed
  import torch.nn
  from numpy.typing import NDArray
  from torch.nn import Module
  from torch.nn.modules.batchnorm import _BatchNorm
  from torch.nn.parameter import Parameter
label_desc: Use image node_id 24 for calling a global function with example usage: get_2d_sincos_pos_embed(embed_dim, grid_size, cls_token) and returns: pos_embed