code: def smooth_one_hot_labels(labels):
      """Convert each label to a one-hot vector."""
      n_classes, label_smooth = (
          cfg.MODEL.NUM_CLASSES,
          cfg.TRAIN.LABEL_SMOOTHING,
      )
      err_str = "Invalid input to one_hot_vector()"
      assert labels.ndim == 1 and labels.max() < n_classes, err_str
      shape = (labels.shape[0], n_classes)
      neg_val = label_smooth / n_classes
      pos_val = 1.0 - label_smooth + neg_val
      labels_one_hot = torch.full(
          shape, neg_val, dtype=torch.float, device=labels.device
      )
      labels_one_hot.scatter_(1, labels.long().view(-1, 1), pos_val)
      return labels_one_hot
  
file_path: pycls/pycls/core/net.py
imports: import itertools
  import numpy
  import pycls.core.distributed
  import torch
  from pycls.core.config import cfg
label_desc: Use image node_id 4 for calling a global function with example usage: smooth_one_hot_labels(labels) and returns: labels_one_hot