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: Returns the total number of `chunksize`-sized chunks
  of the raysampler's rays.
  
  Args:
      chunksize: The number of rays per chunk.
      batch_size: The size of the batch of the raysampler.
  
  Returns:
      n_chunks: The total number of chunks.
docstr_tok: ["Returns","the","total","number","of","`","chunksize","`","-sized","chunks","of","the","raysampler","'s","rays",".","Args",":","chunksize",":","The","number","of","rays","per","chunk",".","batch_size",":","The","size","of","the","batch","of","the","raysampler",".","Returns",":","n_chunks",":","The","total","number","of","chunks","."]
code: def get_n_chunks(self, chunksize: int, batch_size: int):
      """
      Returns the total number of `chunksize`-sized chunks
      of the raysampler's rays.
  
      Args:
          chunksize: The number of rays per chunk.
          batch_size: The size of the batch of the raysampler.
  
      Returns:
          n_chunks: The total number of chunks.
      """
      return int(
          math.ceil(
              (
                  self._grid_raysampler._xy_grid.numel()
                  * 0.5
                  * batch_size
              )
              / chunksize
          )
      )
  
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 2 for calling the NeRFRaysampler obj's underlying member method code with example usage: obj.get_n_chunks(chunksize, batch_size) and returns: int