class_docstr: Model wrapper for coreference resolution.
class_docstr_tok: ["Model","wrapper","for","coreference","resolution","."]
code: def extract_gold_clusters_from_gold_annotation(self, stored_info):
      output_ids = stored_info["target_sentence"]
      cluster_category = stored_info["cluster_category"]
      mention_indice = stored_info["mention_indice"]
  
      if type(output_ids[0]) == str:
          output_ids = [
              self.tz.convert_tokens_to_ids(x) for x in output_ids
          ]
      # mapping from generated sequence index to original index
      mapping = self.get_mapping_to_input_sequence(output_ids)
      subtoken_map = stored_info["subtoken_map"]
  
      # Get predicted clusters
      mention_to_cluster_id = {}
      gold_clusters, mentions = [], []
  
      for i, (category_idx, boundary_idx) in enumerate(
          zip(cluster_category, mention_indice)
      ):
          if category_idx == -1:
              continue
          # Add mention to cluster
          mention = (
              int(subtoken_map[mapping[boundary_idx]]),
              int(subtoken_map[mapping[i]]),
          )
          mentions.append(mention)
          while category_idx >= len(gold_clusters):
              gold_clusters.append([])
  
          gold_clusters[category_idx].append(mention)
          mention_to_cluster_id[mention] = category_idx
  
      gold_clusters = [tuple(c) for c in gold_clusters if len(c) > 1]
      mention_to_gold = {
          m: cluster for cluster in gold_clusters for m in cluster
      }
  
      result_dict = {
          "gold": gold_clusters,
          "mention_to_gold": mention_to_gold,
          "gold_mentions": mentions,
      }
      return result_dict
  
file_path: DeepKE/src/deepke/triple_extraction/ASP/models/model_coref.py
imports: import sys
  import os
  import torch
  import torch.nn
  import logging
  from transformers import T5Tokenizer
  from .t5_coref import T5Coref
label_desc: Use image node_id 8 for calling the CorefModel obj's underlying member method code with example usage: obj.extract_gold_clusters_from_gold_annotation(stored_info) and returns: result_dict