code: def get_labeled_nodes_label_attribute(
      train_mask_zs, labels, features, cuda
  ):
      """Replace the original labels by their class-centers.
      For each label c in the training set, the following operations will be performed:
      Get label_attribute{} through function get_label_attributes, then res[i, :] = label_attribute[c]
      Input: train_mask_zs, labels, features
      Output: Y_{semantic} [l, ft]: tensor
      """
      X = torch.LongTensor(range(features.shape[0]))
      nodeids = []
      labellist = []
      for i in X[train_mask_zs].numpy().tolist():
          nodeids.append(str(i))
      for i in labels[train_mask_zs].cpu().numpy().tolist():
          labellist.append([str(i)])
  
      # 1. get the semantic knowledge (class centers) of all seen classes
      label_attribute = get_label_attributes(
          train_mask_zs=train_mask_zs,
          nodeids=nodeids,
          labellist=labellist,
          features=features.cpu().numpy(),
      )
  
      # 2. replace original labels by their class centers (semantic knowledge)
      res = np.zeros([len(nodeids), features.shape[1]])
      for i, labels in enumerate(labellist):
          # support mutiple labels
          c = len(labels)
          temp = np.zeros([c, features.shape[1]])
          for ii, label in enumerate(labels):
              temp[ii, :] = label_attribute[int(label)]
          temp = np.mean(temp, axis=0)
          res[i, :] = temp
      if cuda:
          res = torch.FloatTensor(res).cuda()
      else:
          res = torch.FloatTensor(res)
      return res
  
imports: from collections import defaultdict
  import numpy
  import torch
label_desc: Use image node_id 4 for calling a global function with example usage: get_labeled_nodes_label_attribute(train_mask_zs, labels, features, cuda) and returns: res