code: def test_label_smoothed_cross_entropy_loss_forward_source_probs(self):
      torch.manual_seed(1)
      np.random.seed(1)
  
      beta = 0.1
      reduce = False
      num_classes = 2
      input_size = 2
      logits = torch.Tensor([[0.5, 0.5], [0.5, 0.5]])
      targets = torch.randint(num_classes, (input_size,))
      padding_indices = 0
      targets[padding_indices] = -100
  
      # Only testing for None now because unexpected behavior with nll_loss.
      # Look at definition of LabelSmoothedCrossEntropyLoss for more
      # context.
      weight = None
  
      manual_loss = self._compute_loss_manual(
          logits,
          targets,
          weight=weight,
          reduce=reduce,
          beta=beta,
          ignore_index=-100,
      )
      loss_fn = LabelSmoothedCrossEntropyLoss(
          config=LabelSmoothedCrossEntropyLoss.Config(
              source=SourceType.PROBS
          ),
          ignore_index=-100,
          weight=weight,
      )
      label_smoothed_loss = loss_fn(logits, targets, reduce=reduce)
  
      diff = np.array(manual_loss) - np.array(label_smoothed_loss)
      error = np.linalg.norm(diff)
      self.assertAlmostEqual(error, 0.0, places=4)
  
file_path: pytext/pytext/loss/tests/label_smoothing_loss_test.py
imports: import caffe2.python.hypothesis_test_util
  import numpy
  import torch
  from pytext.loss.loss import LabelSmoothedCrossEntropyLoss, SourceType
  from scipy.special import logsumexp
label_desc: Use image node_id 2 for calling the LabelSmoothedCrossEntropyLossTest obj's underlying member method code with example usage: obj.test_label_smoothed_cross_entropy_loss_forward_source_probs() without return types