code: def label_smoothing_dist(odim, lsm_type, transcript=None, blank=0):
      """Obtain label distribution for loss smoothing.
  
      :param odim:
      :param lsm_type:
      :param blank:
      :param transcript:
      :return:
      """
      if transcript is not None:
          with open(transcript, "rb") as f:
              trans_json = json.load(f)["utts"]
  
      if lsm_type == "unigram":
          assert transcript is not None, (
              "transcript is required for %s label smoothing" % lsm_type
          )
          labelcount = np.zeros(odim)
          for k, v in trans_json.items():
              ids = np.array(
                  [int(n) for n in v["output"][0]["tokenid"].split()]
              )
              # to avoid an error when there is no text in an uttrance
              if len(ids) > 0:
                  labelcount[ids] += 1
          labelcount[odim - 1] = len(transcript)  # count <eos>
          labelcount[labelcount == 0] = 1  # flooring
          labelcount[blank] = 0  # remove counts for blank
          labeldist = labelcount.astype(np.float32) / np.sum(labelcount)
      else:
          logging.error(
              "Error: unexpected label smoothing type: %s" % lsm_type
          )
          sys.exit()
  
      return labeldist
  
file_path: espnet/espnet/nets/e2e_asr_common.py
imports: import json
  import logging
  import sys
  from itertools import groupby
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: label_smoothing_dist(odim, lsm_type, transcript, blank) and returns: labeldist