code: def read_label_map(label_filename):
      with open(label_filename, encoding="utf-8") as fin:
          lines = fin.readlines()
      lines = [x.strip() for x in lines]
      lines = [x.split() for x in lines if x]
      label_map = {}
      for line_idx, line in enumerate(lines):
          k = line[0].split("#")[1]
          v = line[1]
  
          # compensate for an off-by-one error in the labels for ids 12 through 129
          # we went back and forth a few times but i couldn't explain the error,
          # so whatever, just compensate for it on the conversion side
          k_idx = int(k.split("_")[1])
          if k_idx != line_idx + 1:
              if k_idx >= 12 and k_idx <= 129:
                  k = "sent_%05d" % (k_idx - 1)
              else:
                  raise ValueError(
                      "Unexpected key offset for line {}: {}".format(
                          line_idx, line
                      )
                  )
  
          if v == "neg":
              v = "0"
          elif v == "pos":
              v = "1"
          else:
              raise ValueError(
                  "Unexpected label %s for key %s" % (v, k)
              )
  
          if k in label_map:
              raise ValueError(
                  "Duplicate key %s: new value %s, old value %s"
                  % (k, v, label_map[k])
              )
          label_map[k] = v
  
      return label_map
  
imports: import os
  from stanza.models.classifiers.data import SentimentDatum
  from stanza.utils.datasets.sentiment import process_utils
  from stanza.utils.datasets.constituency.convert_it_vit import read_updated_trees
  import stanza.utils.default_paths
label_desc: Use image node_id 2 for calling a global function with example usage: read_label_map(label_filename) and returns: label_map