code: def _compute_idxs(vals, counts):  # pragma: no cover
      """
      Copied from meshrcnn codebase:
      https://github.com/facebookresearch/meshrcnn/blob/main/shapenet/utils/binvox_torch.py#L58
  
      Fast vectorized version of index computation.
  
      Args:
          vals: tensor of binary values indicating voxel presence in a dense format.
          counts: tensor of number of occurrence of each value in vals.
  
      Returns:
          idxs: A tensor of shape (N), where N is the number of nonzero voxels.
      """
      # Consider an example where:
      # vals   = [0, 1, 0, 1, 1]
      # counts = [2, 3, 3, 2, 1]
      #
      # These values of counts and vals mean that the dense binary grid is:
      # [0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1]
      #
      # So the nonzero indices we want to return are:
      # [2, 3, 4, 8, 9, 10]
  
      # After the cumsum we will have:
      # end_idxs = [2, 5, 8, 10, 11]
      end_idxs = counts.cumsum(dim=0)
  
      # After masking and computing start_idx we have:
      # end_idxs   = [5, 10, 11]
      # counts     = [3,  2,  1]
      # start_idxs = [2,  8, 10]
      mask = vals == 1
      end_idxs = end_idxs[mask]
      counts = counts[mask].to(end_idxs)
      start_idxs = end_idxs - counts
  
      # We initialize delta as:
      # [2, 1, 1, 1, 1, 1]
      delta = torch.ones(counts.sum().item(), dtype=torch.int64)
      delta[0] = start_idxs[0]
  
      # We compute pos = [3, 5], val = [3, 0]; then delta is
      # [2, 1, 1, 4, 1, 1]
      pos = counts.cumsum(dim=0)[:-1]
      val = start_idxs[1:] - end_idxs[:-1]
      delta[pos] += val
  
      # A final cumsum gives the idx we want: [2, 3, 4, 8, 9, 10]
      idxs = delta.cumsum(dim=0)
      return idxs
  
imports: import math
  from typing import Dict, List
  import numpy
  import torch
  from pytorch3d.common.datatypes import Device
  from pytorch3d.datasets.utils import collate_batched_meshes
  from pytorch3d.ops import cubify
  from pytorch3d.renderer import HardPhongShader, MeshRasterizer, MeshRenderer, PointLights, RasterizationSettings, TexturesVertex
  from pytorch3d.renderer.cameras import CamerasBase
  from pytorch3d.transforms import Transform3d
label_desc: Use image node_id 4 for calling a global function with example usage: _compute_idxs(vals, counts) and returns: idxs