code: def non_uniform_sampling(
      error_map: torch.Tensor,
      batch_size: int,
      num_samples: int,
      height: int,
      width: int,
      device: torch.device = "cuda",
  ) -> torch.Tensor:
      """
      Perform non-uniform sampling based on the provided error_map.
  
      Parameters:
          error_map: The error map for non-uniform sampling.
          batch_size (int): Batch size of the generated samples.
          num_samples (int): Number of samples to pick.
          height (int): Height of the image.
          width (int): Width of the image.
          device: Device on which tensors are stored.
  
      Returns:
          A tensor containing the sampled indices.
      """
  
      sampled_indices_coarse = torch.multinomial(
          error_map.to(device), num_samples, replacement=False
      )
      inds_x, inds_y = (
          sampled_indices_coarse // 128,
          sampled_indices_coarse % 128,
      )
      sx, sy = height / 128, width / 128
  
      inds_x = (
          (
              inds_x * sx
              + torch.rand(batch_size, num_samples, device=device) * sx
          )
          .long()
          .clamp(max=height - 1)
      )
      inds_y = (
          (
              inds_y * sy
              + torch.rand(batch_size, num_samples, device=device) * sy
          )
          .long()
          .clamp(max=width - 1)
      )
      sampled_indices = inds_x * width + inds_y
  
      return sampled_indices, sampled_indices_coarse
  
file_path: NeMo/nemo/collections/multimodal/data/nerf/utils.py
imports: from typing import Dict, Optional
  import numpy
  import torch
  import torch.nn.functional
label_desc: Use image node_id 5 for calling a global function with example usage: non_uniform_sampling(error_map, batch_size, num_samples, height, width, device) and returns: sampled_indices,  sampled_indices_coarse