docstr: packbits, CUDA implementation
  Pack up the density grid into a bit field to accelerate ray marching.
  Args:
      grid: float, [C, H * H * H], assume H % 2 == 0
      thresh: float, threshold
  Returns:
      bitfield: uint8, [C, H * H * H / 8]
docstr_tok: ["packbits",",","CUDA","implementation","Pack","up","the","density","grid","into","a","bit","field","to","accelerate","ray","marching",".","Args",":","grid",":","float",",","[","C",",","H","*","H","*","H","]",",","assume","H","%","2","==","0","thresh",":","float",",","threshold","Returns",":","bitfield",":","uint8",",","[","C",",","H","*","H","*","H","\/","8","]"]
code: def forward(ctx, grid, thresh, bitfield=None):
      """packbits, CUDA implementation
      Pack up the density grid into a bit field to accelerate ray marching.
      Args:
          grid: float, [C, H * H * H], assume H % 2 == 0
          thresh: float, threshold
      Returns:
          bitfield: uint8, [C, H * H * H / 8]
      """
      if not grid.is_cuda:
          grid = grid.cuda()
      grid = grid.contiguous()
  
      C = grid.shape[0]
      H3 = grid.shape[1]
      N = C * H3 // 8
  
      if bitfield is None:
          bitfield = torch.empty(
              N, dtype=torch.uint8, device=grid.device
          )
  
      get_backend().packbits(grid, N, thresh, bitfield)
  
      return bitfield
  
imports: import torch
  from torch.autograd import Function
  from torch.cuda.amp import custom_bwd, custom_fwd
label_desc: Use image node_id 1 for calling the _packbits obj's underlying member method code with example usage: obj.forward(ctx, grid, thresh, bitfield) and returns: bitfield