class_docstr: If num_to_sample is provided, sample exactly
  num_to_sample points. Otherwise sample floor(pos[0] * ratio) points
class_docstr_tok: ["If","num_to_sample","is","provided",",","sample","exactly","num_to_sample","points",".","Otherwise","sample","floor","(","pos","[","0","]","*","ratio",")","points"]
code: def sample(self, pos=None, x=None, batch=None):
      if len(pos.shape) != 2:
          raise ValueError(
              "This class is for sparse data and expects the pos tensor to be of dimension 2"
          )
  
      pool = voxel_grid(pos, batch, self._subsampling_param)
      pool, perm = consecutive_cluster(pool)
      batch = pool_batch(perm, batch)
      if x is not None:
          return pool_pos(pool, x), pool_pos(pool, pos), batch
      else:
          return None, pool_pos(pool, pos), batch
  
imports: from abc import ABC, abstractmethod
  import math
  import torch
  from torch_geometric.nn import voxel_grid
  from torch_geometric.nn.pool.consecutive import consecutive_cluster
  from torch_geometric.nn.pool.pool import pool_pos, pool_batch
  import torch_points_kernels
  from torch_points3d.utils.config import is_list
  from torch_points3d.utils.enums import ConvolutionFormat
label_desc: Use image node_id 1 for calling the GridSampler obj's underlying member method code with example usage: obj.sample(pos, x, batch) and returns: pool_pos,  pool_pos,  batch, None,  pool_pos,  batch