class_docstr: Implements the raysampler of NeRF.
  
  Depending on the `self.training` flag, the raysampler either samples
  a chunk of random rays (`self.training==True`), or returns a subset of rays
  of the full image grid (`self.training==False`).
  The chunking of rays allows for efficient evaluation of the NeRF implicit
  surface function without encountering out-of-GPU-memory errors.
  
  Additionally, this raysampler supports pre-caching of the ray bundles
  for a set of input cameras (`self.precache_rays`).
  Pre-caching the rays before training greatly speeds-up the ensuing
  raysampling step of the training NeRF iterations.
class_docstr_tok: ["Implements","the","raysampler","of","NeRF",".","Depending","on","the","`","self.training","`","flag",",","the","raysampler","either","samples","a","chunk","of","random","rays","(","`","self.training==True","`",")",",","or","returns","a","subset","of","rays","of","the","full","image","grid","(","`","self.training==False","`",")",".","The","chunking","of","rays","allows","for","efficient","evaluation","of","the","NeRF","implicit","surface","function","without","encountering","out-of-GPU-memory","errors",".","Additionally",",","this","raysampler","supports","pre-caching","of","the","ray","bundles","for","a","set","of","input","cameras","(","`","self.precache_rays","`",")",".","Pre-caching","the","rays","before","training","greatly","speeds-up","the","ensuing","raysampling","step","of","the","training","NeRF","iterations","."]
docstr: Normalizes the ray directions of the input `RayBundle` to unit norm.
docstr_tok: ["Normalizes","the","ray","directions","of","the","input","`","RayBundle","`","to","unit","norm","."]
code: def _normalize_raybundle(self, ray_bundle: RayBundle):
      """
      Normalizes the ray directions of the input `RayBundle` to unit norm.
      """
      ray_bundle = ray_bundle._replace(
          directions=torch.nn.functional.normalize(
              ray_bundle.directions, dim=-1
          )
      )
      return ray_bundle
  
file_path: pytorch3d/projects/nerf/nerf/raysampler.py
imports: import math
  from typing import List
  import torch
  from pytorch3d.renderer import MonteCarloRaysampler, NDCMultinomialRaysampler, RayBundle
  from pytorch3d.renderer.cameras import CamerasBase
  from pytorch3d.renderer.implicit.sample_pdf import sample_pdf
label_desc: Use image node_id 6 for calling the NeRFRaysampler obj's underlying member method code with example usage: obj._normalize_raybundle(ray_bundle) and returns: ray_bundle