docstr: save patch to load it offline for the training
docstr_tok: ["save","patch","to","load","it","offline","for","the","training"]
code: def _save_patches(self, mod):
      """
      save patch to load it offline for the training
      """
      p_extractor = PatchExtractor(self.radius_patch)
      out_dir = osp.join(self.processed_dir, mod, "patches")
      if files_exist([out_dir]):  # pragma: no cover
          return
      makedirs(out_dir)
      match_dir = osp.join(self.processed_dir, mod, "matches")
      idx = 0
      for i in range(len(os.listdir(match_dir))):
          match = np.load(
              osp.join(match_dir, "matches{:06d}.npy".format(i)),
              allow_pickle=True,
          ).item()
  
          for _ in range(self.num_random_pt):
              data_source = torch.load(match["path_source"])
              data_target = torch.load(match["path_target"])
              rand = np.random.randint(0, len(match["pair"]))
              data_source = p_extractor(
                  data_source, match["pair"][rand][0]
              )
              data_target = p_extractor(
                  data_target, match["pair"][rand][1]
              )
              if self.pre_transform_patch is not None:
                  data_source = self.pre_transform_patch(data_source)
                  data_target = self.pre_transform_patch(data_target)
              if self.pre_filter is not None:
                  if self.pre_filter(data_source) and self.pre_filter(
                      data_target
                  ):
                      torch.save(
                          data_source,
                          osp.join(
                              out_dir,
                              "patches_source{:06d}.pt".format(idx),
                          ),
                      )
                      torch.save(
                          data_target,
                          osp.join(
                              out_dir,
                              "patches_target{:06d}.pt".format(idx),
                          ),
                      )
                      idx += 1
              else:
                  torch.save(
                      data_source,
                      osp.join(
                          out_dir, "patches_source{:06d}.pt".format(idx)
                      ),
                  )
                  torch.save(
                      data_target,
                      osp.join(
                          out_dir, "patches_target{:06d}.pt".format(idx)
                      ),
                  )
                  idx += 1
  
imports: import json
  import logging
  import numpy
  import os
  import os.path
  from plyfile import PlyData
  import shutil
  import torch
  from torch_geometric.data import Dataset, download_url, extract_zip
  from torch_geometric.data import Data
  from torch_points3d.datasets.registration.detector import RandomDetector
  from torch_points3d.datasets.registration.utils import rgbd2fragment_rough
  from torch_points3d.datasets.registration.utils import rgbd2fragment_fine
  from torch_points3d.datasets.registration.utils import compute_overlap_and_matches
  from torch_points3d.datasets.registration.utils import to_list
  from torch_points3d.datasets.registration.utils import files_exist
  from torch_points3d.datasets.registration.utils import makedirs
  from torch_points3d.datasets.registration.utils import get_urls
  from torch_points3d.datasets.registration.utils import PatchExtractor
label_desc: Use image node_id 8 for calling the Base3DMatch obj's underlying member method code with example usage: obj._save_patches(mod) without return types