code: def get_labels(dataset):
      """
      Get class labels for dataset
      """
  
      dataset_type = type(dataset)
      if dataset_type is torchvision.datasets.SVHN:
          return dataset.labels
      if dataset_type is torchvision.datasets.ImageFolder:
          return np.array(dataset.targets)
  
      # Handle subset, recurses into non-subset version
      if dataset_type is torch.utils.data.Subset:
          indices = dataset.indices
          all_labels = get_labels(dataset.dataset)
          logging.debug(
              f"data subset of len {len(indices)} from {len(all_labels)}"
          )
          labels = all_labels[indices]
          if isinstance(labels, torch.Tensor):
              return labels.numpy()
          return labels
  
      try:
          logging.debug(dataset.targets.shape, type(dataset.targets))
          if isinstance(dataset.targets, torch.Tensor):
              return dataset.targets.numpy()
          return dataset.targets
      except AttributeError:
          logging.error(type(dataset))
  
imports: import logging
  import numpy
  import torch.utils.data
  import torchvision
  from torch.utils.data.sampler import BatchSampler, RandomSampler
label_desc: Use image node_id 1 for calling a global function with example usage: get_labels(dataset) and returns: dataset, np, labels, dataset, labels, dataset