code: def render_smpl_nerf(
      net,
      cap,
      posed_verts,
      faces,
      Ts,
      rays_per_batch=32768,
      samples_per_ray=64,
      white_bkg=True,
      render_can=False,
      geo_threshold=DEFAULT_GEO_THRESH,
      return_depth=False,
      return_mask=False,
      interval_comp=1.0,
  ):
      device = next(net.parameters()).device
  
      def build_batch(origins, dirs, near, far):
          if isinstance(origins, torch.Tensor):
              ray_batch = {
                  "origin": (origins).float().to(device),
                  "direction": (dirs).float().to(device),
                  "near": (near[..., None]).float().to(device),
                  "far": (far[..., None]).float().to(device),
              }
          else:
              ray_batch = {
                  "origin": torch.from_numpy(origins)
                  .float()
                  .to(device),
                  "direction": torch.from_numpy(dirs)
                  .float()
                  .to(device),
                  "near": torch.from_numpy(near[..., None])
                  .float()
                  .to(device),
                  "far": torch.from_numpy(far[..., None])
                  .float()
                  .to(device),
              }
          return ray_batch
  
      with torch.set_grad_enabled(False):
          coords = np.argwhere(np.ones(cap.shape))[:, ::-1]
          origins, dirs = ray_utils.shot_rays(cap, coords)
          origins, dirs = torch.from_numpy(origins).to(
              device
          ), torch.from_numpy(dirs).to(device)
          posed_verts = torch.from_numpy(posed_verts).to(device)
          total_rays = origins.shape[0]
          total_rgb_map = []
          total_depth_map = []
          total_acc_map = []
          for i in range(0, total_rays, rays_per_batch):
              print(f"{i} / {total_rays}")
              rgb_map = torch.zeros_like(
                  origins[i : i + rays_per_batch]
              ).to(device)
              depth_map = torch.zeros_like(
                  origins[i : i + rays_per_batch, 0]
              ).to(device)
              acc_map = torch.zeros_like(
                  origins[i : i + rays_per_batch, 0]
              ).to(device)
              temp_near, temp_far = ray_utils.geometry_guided_near_far(
                  origins[i : i + rays_per_batch],
                  dirs[i : i + rays_per_batch],
                  posed_verts,
                  geo_threshold,
              )
              if (temp_near >= temp_far).any():
                  if white_bkg:
                      rgb_map[temp_near >= temp_far] = 1.0
                  else:
                      rgb_map[temp_near >= temp_far] = 0.0
                  depth_map[temp_near >= temp_far] = 0.0
                  acc_map[temp_near >= temp_far] = 0.0
              if (temp_near < temp_far).any():
                  ray_batch = build_batch(
                      origins[i : i + rays_per_batch][
                          temp_near < temp_far
                      ],
                      dirs[i : i + rays_per_batch][
                          temp_near < temp_far
                      ],
                      temp_near[temp_near < temp_far],
                      temp_far[temp_near < temp_far],
                  )
                  _pts, _dirs, _z_vals = ray_utils.ray_to_samples(
                      ray_batch, samples_per_ray, device=device
                  )
                  if render_can:
                      can_pts = _pts
                      can_dirs = _dirs
                  else:
                      (
                          can_pts,
                          can_dirs,
                          _,
                      ) = ray_utils.warp_samples_to_canonical(
                          _pts.cpu().numpy(),
                          posed_verts.cpu().numpy(),
                          faces,
                          Ts,
                      )
                      can_pts = torch.from_numpy(can_pts)
                      can_dirs = torch.from_numpy(can_dirs)
                  can_pts = can_pts.to(device).float()
                  can_dirs = can_dirs.to(device).float()
                  out = net.coarse_human_net(can_pts, can_dirs)
                  out[..., -1] *= interval_comp
                  _rgb_map, _, _acc_map, _, _depth_map = raw2outputs(
                      out, _z_vals, _dirs[:, 0, :], white_bkg=white_bkg
                  )
                  rgb_map[temp_near < temp_far] = _rgb_map
                  depth_map[temp_near < temp_far] = _depth_map
                  acc_map[temp_near < temp_far] = _acc_map
              total_rgb_map.append(rgb_map)
              total_depth_map.append(depth_map)
              total_acc_map.append(acc_map)
          total_rgb_map = (
              torch.cat(total_rgb_map)
              .reshape(*cap.shape, -1)
              .detach()
              .cpu()
              .numpy()
          )
          total_depth_map = (
              torch.cat(total_depth_map)
              .reshape(*cap.shape)
              .detach()
              .cpu()
              .numpy()
          )
          total_acc_map = (
              torch.cat(total_acc_map)
              .reshape(*cap.shape)
              .detach()
              .cpu()
              .numpy()
          )
      if return_depth and return_mask:
          return total_rgb_map, total_depth_map, total_acc_map
      if return_depth:
          return total_rgb_map, total_depth_map
      if return_mask:
          return total_rgb_map, total_acc_map
      return total_rgb_map
  
file_path: ml-neuman/utils/render_utils.py
imports: import random
  import numpy
  import torch
  import torch.nn.functional
  from pytorch3d.structures import Meshes
  from pytorch3d.renderer import RasterizationSettings, MeshRenderer, MeshRasterizer, HardPhongShader, PointLights, TexturesVertex, PerspectiveCameras
  from PIL import Image
  from cameras.camera_pose import CameraPose
  from utils import ray_utils
  from utils.constant import DEFAULT_GEO_THRESH
  from geometry import transformations
label_desc: Use image node_id 5 for calling a global function with example usage: render_smpl_nerf(net, cap, posed_verts, faces, Ts, rays_per_batch, samples_per_ray, white_bkg, render_can, geo_threshold, return_depth, return_mask, interval_comp) and returns: total_rgb_map, ray_batch, total_rgb_map,  total_depth_map,  total_acc_map, total_rgb_map,  total_depth_map, total_rgb_map,  total_acc_map