code: def on_validation_epoch_start(self) -> None:
      if self._train_features and self._train_targets:
          # Features and targets have size (world_size, batch_size, dim) and
          # (world_size, batch_size) after gather. For non-distributed training,
          # features and targets have size (batch_size, dim) and (batch_size,).
          features = self.all_gather(
              torch.cat(self._train_features, dim=0)
          )
          self._train_features = []
          targets = self.all_gather(
              torch.cat(self._train_targets, dim=0)
          )
          self._train_targets = []
          # Reshape to (dim, world_size * batch_size)
          features = features.flatten(end_dim=-2).t().contiguous()
          self._train_features_tensor = features.to(self.device)
          # Reshape to (world_size * batch_size,)
          targets = targets.flatten().t().contiguous()
          self._train_targets_tensor = targets.to(self.device)
  
file_path: lightly/lightly/utils/benchmarking/knn_classifier.py
imports: from typing import Tuple, Union
  import torch
  import torch.nn.functional
  from pytorch_lightning import LightningModule
  from torch import Tensor
  from torch.nn import Module
  from lightly.utils.benchmarking import knn_predict
  from lightly.utils.benchmarking.topk import mean_topk_accuracy
label_desc: Use image node_id 4 for calling the KNNClassifier obj's underlying member method code with example usage: obj.on_validation_epoch_start() without return types