code: def forward(self, sdf, cam_loc, object_mask, ray_directions):
      batch_size, num_pixels, _ = ray_directions.shape
  
      (
          sphere_intersections,
          mask_intersect,
      ) = rend_util.get_sphere_intersection(
          cam_loc, ray_directions, r=self.object_bounding_sphere
      )
  
      (
          curr_start_points,
          unfinished_mask_start,
          acc_start_dis,
          acc_end_dis,
          min_dis,
          max_dis,
      ) = self.sphere_tracing(
          batch_size,
          num_pixels,
          sdf,
          cam_loc,
          ray_directions,
          mask_intersect,
          sphere_intersections,
      )
  
      network_object_mask = acc_start_dis < acc_end_dis
  
      # The non convergent rays should be handled by the sampler
      sampler_mask = unfinished_mask_start
      sampler_net_obj_mask = (
          torch.zeros_like(sampler_mask).bool().cuda()
      )
      if sampler_mask.sum() > 0:
          sampler_min_max = torch.zeros(
              (batch_size, num_pixels, 2)
          ).cuda()
          sampler_min_max.reshape(-1, 2)[
              sampler_mask, 0
          ] = acc_start_dis[sampler_mask]
          sampler_min_max.reshape(-1, 2)[sampler_mask, 1] = acc_end_dis[
              sampler_mask
          ]
  
          (
              sampler_pts,
              sampler_net_obj_mask,
              sampler_dists,
          ) = self.ray_sampler(
              sdf,
              cam_loc,
              object_mask,
              ray_directions,
              sampler_min_max,
              sampler_mask,
          )
  
          curr_start_points[sampler_mask] = sampler_pts[sampler_mask]
          acc_start_dis[sampler_mask] = sampler_dists[sampler_mask]
          network_object_mask[sampler_mask] = sampler_net_obj_mask[
              sampler_mask
          ]
  
      print(
          "----------------------------------------------------------------"
      )
      print(
          "RayTracing: object = {0}/{1}, secant on {2}/{3}.".format(
              network_object_mask.sum(),
              len(network_object_mask),
              sampler_net_obj_mask.sum(),
              sampler_mask.sum(),
          )
      )
      print(
          "----------------------------------------------------------------"
      )
  
      if not self.training:
          return curr_start_points, network_object_mask, acc_start_dis
  
      ray_directions = ray_directions.reshape(-1, 3)
      mask_intersect = mask_intersect.reshape(-1)
  
      in_mask = ~network_object_mask & object_mask & ~sampler_mask
      out_mask = ~object_mask & ~sampler_mask
  
      mask_left_out = (in_mask | out_mask) & ~mask_intersect
      if (
          mask_left_out.sum() > 0
      ):  # project the origin to the not intersect points on the sphere
          cam_left_out = (
              cam_loc.unsqueeze(1)
              .repeat(1, num_pixels, 1)
              .reshape(-1, 3)[mask_left_out]
          )
          rays_left_out = ray_directions[mask_left_out]
          acc_start_dis[mask_left_out] = -torch.bmm(
              rays_left_out.view(-1, 1, 3), cam_left_out.view(-1, 3, 1)
          ).squeeze()
          curr_start_points[mask_left_out] = (
              cam_left_out
              + acc_start_dis[mask_left_out].unsqueeze(1)
              * rays_left_out
          )
  
      mask = (in_mask | out_mask) & mask_intersect
  
      if mask.sum() > 0:
          min_dis[network_object_mask & out_mask] = acc_start_dis[
              network_object_mask & out_mask
          ]
  
          min_mask_points, min_mask_dist = self.minimal_sdf_points(
              num_pixels,
              sdf,
              cam_loc,
              ray_directions,
              mask,
              min_dis,
              max_dis,
          )
  
          curr_start_points[mask] = min_mask_points
          acc_start_dis[mask] = min_mask_dist
  
      return curr_start_points, network_object_mask, acc_start_dis
  
file_path: insightface/reconstruction/PBIDR/code/model/ray_tracing.py
imports: import torch
  import torch.nn
  from utils import rend_util
label_desc: Use image node_id 2 for calling the RayTracing obj's underlying member method code with example usage: obj.forward(sdf, cam_loc, object_mask, ray_directions) and returns: curr_start_points,  network_object_mask,  acc_start_dis, curr_start_points,  network_object_mask,  acc_start_dis