code: def get_2d_sincos_pos_embed_from_grid(
      embed_dim: int, grid: NDArray[np.int_]
  ) -> NDArray[np.float_]:
      """Returns 2D sin-cos embeddings grid. Code from [0].
  
      - [0]: https://github.com/facebookresearch/ijepa
  
      Args:
          embed_dim:
              Embedding dimension.
          grid:
              2-dimensional grid to embed.
  
      Returns:
          Positional embeddings array with size (grid_size * grid_size, embed_dim).
      """
      assert embed_dim % 2 == 0
  
      # use half of dimensions to encode grid_h
      emb_h = get_1d_sincos_pos_embed_from_grid(
          embed_dim // 2, grid[0]
      )  # (H*W, D/2)
      emb_w = get_1d_sincos_pos_embed_from_grid(
          embed_dim // 2, grid[1]
      )  # (H*W, D/2)
  
      emb = np.concatenate([emb_h, emb_w], axis=1)  # (H*W, D)
      return emb
  
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 25 for calling a global function with example usage: get_2d_sincos_pos_embed_from_grid(embed_dim, grid) and returns: emb