code: def initialize_label_smoothing_constants(self):
      assert self.label_smoothing_matrix is not None
      self.label_smoothing_matrix = np.array(
          self.label_smoothing_matrix
      ).astype(np.float32)
      assert len(self.label_smoothing_matrix.shape) == 2
      label_dim = self.label_smoothing_matrix.shape[0]
      assert label_dim == self.label_smoothing_matrix.shape[1]
  
      self.label_smoothing_matrix = self.model.add_global_constant(
          "%s_label_smoothing_matrix" % self.name,
          array=self.label_smoothing_matrix,
          dtype=np.dtype(np.float32),
      )
      self.label_dim = self.model.add_global_constant(
          "%s_label_dim" % self.name,
          array=label_dim,
          dtype=np.dtype(np.int64),
      )
      # default case: label is given NOT as target distribution
      # but when used in label smoothing, the label must be in probabilities
      self.label_prob = True
  
file_path: pytorch/caffe2/python/layers/batch_softmax_loss.py
imports: from caffe2.python import core, schema
  from caffe2.python.layers.layers import ModelLayer
  import numpy
label_desc: Use image node_id 2 for calling the BatchSoftmaxLoss obj's underlying member method code with example usage: obj.initialize_label_smoothing_constants() without return types