code: def render_image_with_occgrid(
      # scene
      nerf: torch.nn.Module,
      estimator: OccGridEstimator,
      rays: Rays,
      # rendering options
      near_plane: float = 0.0,
      far_plane: float = 1e10,
      render_step_size: float = 1e-3,
      render_bkgd: Optional[torch.Tensor] = None,
      cone_angle: float = 0.0,
      alpha_thre: float = 0.0,
      # test options
      test_chunk_size: int = 8192,
  ):
      """Render the pixels of an image."""
      rays_shape = rays.origins.shape
      if len(rays_shape) == 3:
          height, width, _ = rays_shape
          num_rays = height * width
          rays = namedtuple_map(
              lambda r: r.reshape([num_rays] + list(r.shape[2:])), rays
          )
      else:
          num_rays, _ = rays_shape
  
      # TODO(ahmadki): optimize, cache result between sigma_fn and rgb_sigma_fn
      def sigma_fn(t_starts, t_ends, ray_indices):
          t_origins = chunk_rays.origins[ray_indices]
          t_dirs = chunk_rays.viewdirs[ray_indices]
          positions = (
              t_origins + t_dirs * (t_starts + t_ends)[:, None] / 2.0
          )
          sigmas = nerf.density(positions)["sigma"]
          return sigmas
  
      def rgb_sigma_fn(t_starts, t_ends, ray_indices):
          t_origins = chunk_rays.origins[ray_indices]
          t_dirs = chunk_rays.viewdirs[ray_indices]
          positions = (
              t_origins + t_dirs * (t_starts + t_ends)[:, None] / 2.0
          )
          sigmas, rgbs, normal = nerf(
              positions=positions, view_dirs=None, light_dirs=t_dirs
          )  # TODO(ahmadki): t_dirs is incorrect
          return rgbs, sigmas
  
      results = []
      chunk = (
          torch.iinfo(torch.int32).max
          if nerf.training
          else test_chunk_size
      )
  
      for i in range(0, num_rays, chunk):
          chunk_rays = namedtuple_map(lambda r: r[i : i + chunk], rays)
          ray_indices, t_starts, t_ends = estimator.sampling(
              chunk_rays.origins,
              chunk_rays.viewdirs,
              sigma_fn=sigma_fn,
              near_plane=near_plane,
              far_plane=far_plane,
              render_step_size=render_step_size,
              stratified=nerf.training,
              cone_angle=cone_angle,
              alpha_thre=alpha_thre,
          )
          rgb, opacity, depth, extras = rendering(
              t_starts,
              t_ends,
              ray_indices,
              n_rays=chunk_rays.origins.shape[0],
              rgb_sigma_fn=rgb_sigma_fn,
              render_bkgd=render_bkgd,
          )
  
          weight = extras["weights"]
          alpha = extras["alphas"]
  
          chunk_results = [
              rgb,
              opacity,
              depth,
              weight,
              alpha,
              len(t_starts),
          ]
          results.append(chunk_results)
  
      (
          colors,
          opacities,
          depths,
          weights,
          alphas,
          n_rendering_samples,
      ) = [
          torch.cat(r, dim=0) if isinstance(r[0], torch.Tensor) else r
          for r in zip(*results)
      ]
  
      return (
          colors.view((*rays_shape[:-1], -1)),
          opacities.view((*rays_shape[:-1], -1)),
          depths.view((*rays_shape[:-1], -1)),
          weights,
          alphas,
          sum(n_rendering_samples),
      )
  
file_path: NeMo/nemo/collections/multimodal/modules/nerf/renderers/nerfacc_volume_renderer.py
imports: import collections
  from typing import Optional
  import torch
  from nerfacc.estimators.occ_grid import OccGridEstimator
  from nerfacc.grid import ray_aabb_intersect, traverse_grids
  from nerfacc.volrend import accumulate_along_rays_, render_weight_from_density, rendering
  from nemo.collections.multimodal.modules.renderer.base_renderer import BaseRenderer
label_desc: Use image node_id 2 for calling a global function with example usage: render_image_with_occgrid(nerf, estimator, rays, near_plane, far_plane, render_step_size, render_bkgd, cone_angle, alpha_thre, test_chunk_size) and returns: colors,  opacities,  depths,  weights,  alphas,  sum, sigmas, rgbs,  sigmas