code: def __init__(
      self,
      input_dim=3,
      num_levels=16,
      level_dim=2,
      per_level_scale=2,
      base_resolution=16,
      log2_hashmap_size=19,
      desired_resolution=None,
      gridtype="hash",
      align_corners=False,
      interpolation="linear",
  ):
      super().__init__()
  
      # the finest resolution desired at the last level, if provided, overridee per_level_scale
      if desired_resolution is not None:
          per_level_scale = np.exp2(
              np.log2(desired_resolution / base_resolution)
              / (num_levels - 1)
          )
  
      self.input_dim = input_dim  # coord dims, 2 or 3
      self.num_levels = (
          num_levels  # num levels, each level multiply resolution by 2
      )
      self.level_dim = level_dim  # encode channels per level
      self.per_level_scale = per_level_scale  # multiply resolution by this scale at each level.
      self.log2_hashmap_size = log2_hashmap_size
      self.base_resolution = base_resolution
      self.output_dim = num_levels * level_dim
      self.gridtype = gridtype
      self.gridtype_id = _gridtype_to_id[gridtype]  # "tiled" or "hash"
      self.interpolation = interpolation
      self.interp_id = _interp_to_id[
          interpolation
      ]  # "linear" or "smoothstep"
      self.align_corners = align_corners
  
      # allocate parameters
      offsets = []
      offset = 0
      self.max_params = 2**log2_hashmap_size
      for i in range(num_levels):
          resolution = int(
              np.ceil(base_resolution * per_level_scale**i)
          )
          params_in_level = min(
              self.max_params, (resolution) ** input_dim
          )  # limit max number
          params_in_level = int(
              np.ceil(params_in_level / 8) * 8
          )  # make divisible
          offsets.append(offset)
          offset += params_in_level
      offsets.append(offset)
      offsets = torch.from_numpy(np.array(offsets, dtype=np.int32))
      self.register_buffer("offsets", offsets)
  
      self.n_params = offsets[-1] * level_dim
  
      # parameters
      self.embeddings = nn.Parameter(torch.empty(offset, level_dim))
  
      self.reset_parameters()
  
file_path: NeMo/nemo/collections/multimodal/modules/nerf/utils/torch_ngp/gridencoder.py
imports: import math
  import _gridencoder
  import numpy
  import torch
  import torch.nn
  from torch.autograd import Function
  from torch.cuda.amp import custom_bwd, custom_fwd
label_desc: Use image node_id 1 to create a new GridEncoder object from inherited base classes: nn with example: obj = GridEncoder(input_dim, num_levels, level_dim, per_level_scale, base_resolution, log2_hashmap_size, desired_resolution, gridtype, align_corners, interpolation)