Here is a snippet from my implementation, where I basically assign smoothed label to whole tensor and then later add high confidence labels. Note that your case of smoothing might be different and the function is specific for my requirement of computation over a language model -
   with torch.no_grad():
    confidence = 1.0 - smoothing
    low_confidence = (1.0 - confidence) / labels.new_tensor(vocab_size - 1)
    soft_targets = labels.data.new_zeros(*(list(labels.shape)+[vocab_size])) + low_confidence
    soft_targets.scatter_(2, labels.unsqueeze(dim=2).long(), confidence)

   xentropy = softmax_and_cross_entropy(logits, soft_targets)