class_docstr: If num_to_sample is provided, sample exactly
  num_to_sample points. Otherwise sample floor(pos[0] * ratio) points
  This class samples randomly points either in "DENSE" or "PARTIAL_DENSE"
  format and output the sampled points in "DENSE" format
code: def sample(self, data, num_batches, conv_type):
      if conv_type == "DENSE":
          assert (
              self._num_to_sample <= data.pos.shape[1]
          ), "self._num_to_sample: {} should be smaller than num_pos: {}".format(
              self._num_to_sample, data.pos.shape[1]
          )
          idx = torch.randint(
              0,
              data.pos.shape[1],
              (
                  data.pos.shape[0],
                  self._num_to_sample,
              ),
          ).to(data.pos.device)
          data.pos = torch.gather(
              data.pos,
              1,
              idx.unsqueeze(-1).repeat(1, 1, data.pos.shape[-1]),
          )
          data.x = torch.gather(
              data.x, 2, idx.unsqueeze(1).repeat(1, data.x.shape[1], 1)
          )
          return data, idx
      else:
          pos = []
          x = []
          idx_out = []
          num_points = 0
          for batch_idx in range(num_batches):
              batch_mask = data.batch == batch_idx
              pos_masked = data.pos[batch_mask]
              x_masked = data.x[batch_mask]
              assert (
                  self._num_to_sample <= pos_masked.shape[0]
              ), "self._num_to_sample: {} should be smaller than num_pos: {}".format(
                  self._num_to_sample, pos_masked.shape[0]
              )
              idx = torch.randint(
                  0, pos_masked.shape[0], (self._num_to_sample,)
              )
              pos.append(pos_masked[idx])
              x.append(x_masked[idx])
              idx_out.append(idx + num_points)
              num_points += pos_masked.shape[0]
          data.pos = torch.stack(pos)
          data.x = torch.stack(x).permute(0, 2, 1)
          return data, torch.cat(idx_out, dim=0)
  
file_path: torch-points3d/torch_points3d/modules/VoteNet/dense_samplers.py
imports: import torch
  from torch_geometric.data import Data
  from torch_points3d.core.spatial_ops import BaseSampler
label_desc: Use image node_id 1 for calling the RandomSamplerToDense obj's underlying member method code with example usage: obj.sample(data, num_batches, conv_type) and returns: data,  idx, data,  torch