class_docstr: TorchPoints3d Trainer handles the logic between
      - BaseModel,
      - Dataset and its Tracker
      - A custom ModelCheckpoint
      - A custom Visualizer
  It supports MC dropout - multiple voting_runs for val / test datasets
class_docstr_tok: ["TorchPoints3d","Trainer","handles","the","logic","between","-","BaseModel",",","-","Dataset","and","its","Tracker","-","A","custom","ModelCheckpoint","-","A","custom","Visualizer","It","supports","MC","dropout","-","multiple","voting_runs","for","val","\/","test","datasets"]
code: def _test_epoch(self, epoch, stage_name: str):
      voting_runs = self._cfg.get("voting_runs", 1)
      if stage_name == "test":
          loaders = self._dataset.test_dataloaders
      else:
          loaders = [self._dataset.val_dataloader]
  
      self._model.eval()
      if self.enable_dropout:
          self._model.enable_dropout_in_eval()
  
      for loader in loaders:
          stage_name = loader.dataset.name
          self._tracker.reset(stage_name)
          if self.has_visualization:
              self._visualizer.reset(epoch, stage_name)
          if not self._dataset.has_labels(
              stage_name
          ) and not self.tracker_options.get(
              "make_submission", False
          ):  # No label, no submission -> do nothing
              log.warning(
                  "No forward will be run on dataset %s." % stage_name
              )
              continue
  
          with self.profiler_profile(epoch) as prof:
              for i in range(voting_runs):
                  with Ctq(loader) as tq_loader:
                      for data in tq_loader:
                          with torch.no_grad():
                              with self.profiler_record_function(
                                  "test_step"
                              ):
                                  self._model.set_input(
                                      data, self._device
                                  )
                                  with torch.cuda.amp.autocast(
                                      enabled=self._model.is_mixed_precision()
                                  ):
                                      self._model.forward(epoch=epoch)
  
                              with self.profiler_record_function(
                                  "track/log/visualize"
                              ):
                                  self._tracker.track(
                                      self._model,
                                      data=data,
                                      **self.tracker_options,
                                  )
                                  tq_loader.set_postfix(
                                      **self._tracker.get_metrics(),
                                      color=COLORS.TEST_COLOR,
                                  )
  
                                  if (
                                      self.has_visualization
                                      and self._visualizer.is_active
                                  ):
                                      self._visualizer.save_visuals(
                                          self._model.get_current_visuals()
                                      )
  
                          if self.pytorch_profiler_log:
                              prof.step()
  
                          if self.early_break:
                              break
  
                          if self.profiling:
                              if i > self.num_batches:
                                  return 0
  
          self._finalize_epoch(epoch)
          self._tracker.print_summary()
  
imports: import os
  import copy
  import torch
  import hydra
  import time
  import logging
  from tqdm.auto import tqdm
  import wandb
  from torch_points3d.datasets.dataset_factory import instantiate_dataset
  from torch_points3d.models.model_factory import instantiate_model
  from torch_points3d.models.base_model import BaseModel
  from torch_points3d.datasets.base_dataset import BaseDataset
  from torch_points3d.metrics.base_tracker import BaseTracker
  from torch_points3d.metrics.colored_tqdm import Coloredtqdm
  from torch_points3d.metrics.model_checkpoint import ModelCheckpoint
  from torch_points3d.utils.colors import COLORS
  from torch_points3d.utils.wandb_utils import Wandb
  from torch_points3d.visualization import Visualizer
  import torch.profiler
  import torch.autograd.profiler
  from contextlib import nullcontext
label_desc: Use image node_id 7 for calling the Trainer obj's underlying member method code with example usage: obj._test_epoch(epoch, stage_name) and returns: int