code: def tag_mapping_corres(
      predict_tags,
      pre_corres,
      pre_rels=None,
      label2idx_sub=None,
      label2idx_obj=None,
  ):
      """
      Args:
          predict_tags: np.array, (xi, 2, max_sen_len)
          pre_corres: (seq_len, seq_len)
          pre_rels: (xi,)
      """
      rel_num = predict_tags.shape[0]
      pre_triples = []
      for idx in range(rel_num):
          heads, tails = [], []
          pred_chunks_sub = get_chunks(
              predict_tags[idx][0], label2idx_sub
          )
          pred_chunks_obj = get_chunks(
              predict_tags[idx][1], label2idx_obj
          )
          pred_chunks = pred_chunks_sub + pred_chunks_obj
          for ch in pred_chunks:
              if ch[0] == "H":
                  heads.append(ch)
              elif ch[0] == "T":
                  tails.append(ch)
          retain_hts = [
              (h, t)
              for h in heads
              for t in tails
              if pre_corres[h[1]][t[1]] == 1
          ]
          for h_t in retain_hts:
              if pre_rels is not None:
                  triple = list(h_t) + [pre_rels[idx]]
              else:
                  triple = list(h_t) + [idx]
              pre_triples.append(tuple(triple))
      return pre_triples
  
label_desc: Use image node_id 4 for calling a global function with example usage: tag_mapping_corres(predict_tags, pre_corres, pre_rels, label2idx_sub, label2idx_obj) and returns: pre_triples