code: def get_predicted_clusters(
      top_spans, antecedent_indices, predicted_antecedents
  ):
      # Pytorch 0.4 introduced scalar tensors, so our calls to tuple() and such below don't
      # actually give ints unless we convert to numpy first.  So we do that here.
      top_spans = top_spans.numpy()  # (num_spans, 2)
      antecedent_indices = (
          antecedent_indices.numpy()
      )  # (num_spans, num_antecedents)
      predicted_antecedents = (
          predicted_antecedents.numpy()
      )  # (num_spans,)
  
      predicted_clusters_to_ids = {}
      clusters = []
      for i, predicted_antecedent in enumerate(predicted_antecedents):
          if predicted_antecedent < 0:
              continue
  
          # Find predicted index in the antecedent spans.
          predicted_index = antecedent_indices[i, predicted_antecedent]
          # Must be a previous span.
          assert i > predicted_index
          antecedent_span = tuple(top_spans[predicted_index])  # type: ignore
  
          # Check if we've seen the span before.
          if antecedent_span in list(predicted_clusters_to_ids.keys()):
              predicted_cluster_id = predicted_clusters_to_ids[
                  antecedent_span
              ]
          else:
              # We start a new cluster.
              predicted_cluster_id = len(clusters)
              clusters.append([antecedent_span])
              predicted_clusters_to_ids[
                  antecedent_span
              ] = predicted_cluster_id
  
          mention = tuple(top_spans[i])  # type: ignore
          clusters[predicted_cluster_id].append(mention)
          predicted_clusters_to_ids[mention] = predicted_cluster_id
  
      # finalise the spans and clusters.
      final_clusters = [tuple(cluster) for cluster in clusters]
      # Return a mapping of each mention to the cluster containing it.
      mention_to_cluster = dict(
          (mention, final_clusters[cluster_id])
          for mention, cluster_id in list(
              predicted_clusters_to_ids.items()
          )
      )
  
      return final_clusters, mention_to_cluster
  
imports: from __future__ import division
  from __future__ import absolute_import
  from collections import Counter
  from sklearn.utils.linear_assignment_ import linear_assignment
  import numpy
  import torch
  from allennlp.training.metrics.metric import Metric
label_desc: Use image node_id 6 for calling the ConllCorefScores obj's underlying member method code with example usage: obj.get_predicted_clusters(top_spans, antecedent_indices, predicted_antecedents) and returns: final_clusters,  mention_to_cluster