code: def cross_entropy_with_label_smoothing(
      pred, target, label_smoothing=0.1
  ):
      logsoftmax = nn.LogSoftmax()
      n_classes = pred.size(1)
      # convert to one-hot
      target = torch.unsqueeze(target, 1)
      soft_target = torch.zeros_like(pred)
      soft_target.scatter_(1, target, 1)
      # label smoothing
      soft_target = (
          soft_target * (1 - label_smoothing)
          + label_smoothing / n_classes
      )
      return torch.mean(torch.sum(-soft_target * logsoftmax(pred), 1))
  
file_path: nni/examples/nas/legacy/oneshot/proxylessnas/retrain.py
imports: import time
  import math
  from datetime import timedelta
  import torch
  from torch import nn
  from nni.nas.pytorch.utils import AverageMeter
label_desc: Use image node_id 1 for calling a global function with example usage: cross_entropy_with_label_smoothing(pred, target, label_smoothing) and returns: torch