code: def unravel_index(idx, dims) -> torch.Tensor:
      r"""
      Equivalent to np.unravel_index
      Args:
        idx: A LongTensor whose elements are indices into the
            flattened version of an array of dimensions dims.
        dims: The shape of the array to be indexed.
      Implemented only for dims=(N, H, W, D)
      """
      if len(dims) != 4:
          raise ValueError("Expects a 4-element list.")
      N, H, W, D = dims
      n = idx // (H * W * D)
      h = (idx - n * H * W * D) // (W * D)
      w = (idx - n * H * W * D - h * W * D) // D
      d = idx - n * H * W * D - h * W * D - w * D
      return torch.stack((n, h, w, d), dim=1)
  
imports: import torch
  import torch.nn.functional
  from pytorch3d.common.compat import meshgrid_ij
  from pytorch3d.structures import Meshes
label_desc: Use image node_id 1 for calling a global function with example usage: unravel_index(idx, dims) and returns: torch