class_docstr: Model wrapper for coreference resolution.
class_docstr_tok: ["Model","wrapper","for","coreference","resolution","."]
code: def decoding(self, output, stored_info):
      output_ids, pairing_decisions, antecedent_decisions = (
          output["output_ids"].tolist(),
          output["pairing"],
          output["linking"],
      )
      subtoken_map = stored_info["subtoken_map"]
      # mapping from generated sequence index to original index
      mapping = self.get_mapping_to_input_sequence(output_ids)
  
      mentions, start_ind = [], []
      predicted_clusters, antecedent_indices = [], []
  
      mention_to_cluster_id = {}
  
      for i in range(len(output_ids)):
          if output_ids[i] == self.tz.pad_token_id:
              break
          if output_ids[i] == self.mention_start_id:
              start_ind.append(i)
          if output_ids[i] == self.mention_end_id:
              mention = (
                  subtoken_map[
                      mapping[start_ind[pairing_decisions[i]]]
                  ],
                  subtoken_map[mapping[i]],
              )
              mentions.append(mention)
              ant = antecedent_decisions[i]
              if ant == -1:
                  predicted_clusters.append([mention])
                  mention_to_cluster_id[mention] = (
                      len(predicted_clusters) - 1
                  )
              else:
                  antecedent = mentions[ant]
                  predicted_clusters[
                      mention_to_cluster_id[antecedent]
                  ].append(mention)
                  mention_to_cluster_id[
                      mention
                  ] = mention_to_cluster_id[antecedent]
  
      mention_to_predicted = {
          m: tuple(predicted_clusters[cluster_idx])
          for m, cluster_idx in mention_to_cluster_id.items()
      }
      predicted_clusters = [tuple(c) for c in predicted_clusters]
  
      result_dict = {
          "predicted": predicted_clusters,
          "mention_to_predicted": mention_to_predicted,
          "predicted_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 7 for calling the CorefModel obj's underlying member method code with example usage: obj.decoding(output, stored_info) and returns: result_dict