docstr: Convert kitti points(N, >=3) to voxels.
  
  Args:
      points (torch.Tensor): [N, ndim]. Points[:, :3] contain xyz points
          and points[:, 3:] contain other information like reflectivity.
      voxel_size (tuple or float): The size of voxel with the shape of
          [3].
      coors_range (tuple or float): The coordinate range of voxel with
          the shape of [6].
      max_points (int, optional): maximum points contained in a voxel. if
          max_points=-1, it means using dynamic_voxelize. Default: 35.
      max_voxels (int, optional): maximum voxels this function create.
          for second, 20000 is a good choice. Users should shuffle points
          before call this function because max_voxels may drop points.
          Default: 20000.
  
  Returns:
      voxels_out (torch.Tensor): Output voxels with the shape of [M,
          max_points, ndim]. Only contain points and returned when
          max_points != -1.
      coors_out (torch.Tensor): Output coordinates with the shape of
          [M, 3].
      num_points_per_voxel_out (torch.Tensor): Num points per voxel with
          the shape of [M]. Only returned when max_points != -1.
docstr_tok: ["Convert","kitti","points","(","N",",",">","=3",")","to","voxels",".","Args",":","points","(","torch.Tensor",")",":","[","N",",","ndim","]",".","Points","[",":",",",":3","]","contain","xyz","points","and","points","[",":",",","3",":","]","contain","other","information","like","reflectivity",".","voxel_size","(","tuple","or","float",")",":","The","size","of","voxel","with","the","shape","of","[","3","]",".","coors_range","(","tuple","or","float",")",":","The","coordinate","range","of","voxel","with","the","shape","of","[","6","]",".","max_points","(","int",",","optional",")",":","maximum","points","contained","in","a","voxel",".","if","max_points=-1",",","it","means","using","dynamic_voxelize",".","Default",":","35.","max_voxels","(","int",",","optional",")",":","maximum","voxels","this","function","create",".","for","second",",","20000","is","a","good","choice",".","Users","should","shuffle","points","before","call","this","function","because","max_voxels","may","drop","points",".","Default",":","20000",".","Returns",":","voxels_out","(","torch.Tensor",")",":","Output","voxels","with","the","shape","of","[","M",",","max_points",",","ndim","]",".","Only","contain","points","and","returned","when","max_points","!","=","-1.","coors_out","(","torch.Tensor",")",":","Output","coordinates","with","the","shape","of","[","M",",","3","]",".","num_points_per_voxel_out","(","torch.Tensor",")",":","Num","points","per","voxel","with","the","shape","of","[","M","]",".","Only","returned","when","max_points","!","=","-1","."]
code: def forward(
      ctx,
      points,
      voxel_size,
      coors_range,
      max_points=35,
      max_voxels=20000,
  ):
      """Convert kitti points(N, >=3) to voxels.
  
      Args:
          points (torch.Tensor): [N, ndim]. Points[:, :3] contain xyz points
              and points[:, 3:] contain other information like reflectivity.
          voxel_size (tuple or float): The size of voxel with the shape of
              [3].
          coors_range (tuple or float): The coordinate range of voxel with
              the shape of [6].
          max_points (int, optional): maximum points contained in a voxel. if
              max_points=-1, it means using dynamic_voxelize. Default: 35.
          max_voxels (int, optional): maximum voxels this function create.
              for second, 20000 is a good choice. Users should shuffle points
              before call this function because max_voxels may drop points.
              Default: 20000.
  
      Returns:
          voxels_out (torch.Tensor): Output voxels with the shape of [M,
              max_points, ndim]. Only contain points and returned when
              max_points != -1.
          coors_out (torch.Tensor): Output coordinates with the shape of
              [M, 3].
          num_points_per_voxel_out (torch.Tensor): Num points per voxel with
              the shape of [M]. Only returned when max_points != -1.
      """
      if max_points == -1 or max_voxels == -1:
          coors = points.new_zeros(
              size=(points.size(0), 3), dtype=torch.int
          )
          ext_module.dynamic_voxelize_forward(
              points, coors, voxel_size, coors_range, 3
          )
          return coors
      else:
          voxels = points.new_zeros(
              size=(max_voxels, max_points, points.size(1))
          )
          coors = points.new_zeros(
              size=(max_voxels, 3), dtype=torch.int
          )
          num_points_per_voxel = points.new_zeros(
              size=(max_voxels,), dtype=torch.int
          )
          voxel_num = ext_module.hard_voxelize_forward(
              points,
              voxels,
              coors,
              num_points_per_voxel,
              voxel_size,
              coors_range,
              max_points,
              max_voxels,
              3,
          )
          # select the valid voxels
          voxels_out = voxels[:voxel_num]
          coors_out = coors[:voxel_num]
          num_points_per_voxel_out = num_points_per_voxel[:voxel_num]
          return voxels_out, coors_out, num_points_per_voxel_out
  
file_path: lavis/lavis/common/annotator/uniformer/mmcv/ops/voxelize.py
imports: import torch
  from torch import nn
  from torch.autograd import Function
  from torch.nn.modules.utils import _pair
  from ..utils import ext_loader
label_desc: Use image node_id 1 for calling the _Voxelization obj's underlying member method code with example usage: obj.forward(ctx, points, voxel_size, coors_range, max_points, max_voxels) and returns: coors, voxels_out,  coors_out,  num_points_per_voxel_out