class_docstr: Sum cross entropy loss:
  - For a single tensor, this is equivalent to the cross-entropy loss.
  - For a list of tensors, this computes the sum of the cross-entropy
  losses for each tensor in the list against the target.
  
  Can accommodate target vectors, e.g. smoothed labels.
class_docstr_tok: ["Sum","cross","entropy","loss",":","-","For","a","single","tensor",",","this","is","equivalent","to","the","cross-entropy","loss",".","-","For","a","list","of","tensors",",","this","computes","the","sum","of","the","cross-entropy","losses","for","each","tensor","in","the","list","against","the","target",".","Can","accommodate","target","vectors",",","e.g",".","smoothed","labels","."]
code: def apply_label_smoothing(
      target: torch.Tensor, num_labels: int, label_smoothing: float
  ):
      batch_size = target.shape[0]
      smoothed_targets = torch.full(
          size=(batch_size, num_labels),
          fill_value=label_smoothing / num_labels,
          device=target.device,
      )
      one_hot = torch.nn.functional.one_hot(
          target, num_classes=num_labels
      )
      smoothed_targets += (1 - label_smoothing) * one_hot
      return smoothed_targets
  
imports: from dataclasses import dataclass
  from typing import List, Optional, Union
  import torch
  import torch.nn.functional
  from classy_vision.generic.util import is_on_gpu
  from classy_vision.losses import ClassyLoss, register_loss
  from torch import nn, Tensor
  from vissl.config import AttrDict
label_desc: Use image node_id 4 for calling the CrossEntropyMultipleOutputSingleTargetCriterion obj's underlying member method code with example usage: obj.apply_label_smoothing(target, num_labels, label_smoothing) and returns: smoothed_targets