class_docstr: Class for building label mappgings from a label set.
class_docstr_tok: ["Class","for","building","label","mappgings","from","a","label","set","."]
code: def build(cls, saved_label_file, all_labels=None):
      if os.path.exists(saved_label_file):
          print(
              "Loading pre-built label mappings stored in {}".format(
                  saved_label_file
              )
          )
          with open(saved_label_file, "rb") as f:
              label_model = pickle.load(f)
      else:
          label_model = cls(all_labels)
          print("Saving label mappings to {}".format(saved_label_file))
          pickle.dump(label_model, open(saved_label_file, "wb"))
  
      return label_model
  
imports: import os
  import pickle
  from collections import OrderedDict
  import numpy
  import torch
  import torch.nn
  import yaml
  from scipy import sparse
  from sklearn import preprocessing
  from graph4nlp.pytorch.data.data import GraphData
label_desc: Use image node_id 2 for calling the LabelModel obj's underlying member method code with example usage: obj.build(cls, saved_label_file, all_labels) and returns: label_model