class_docstr: Combines all coref modules together to find coreferent spans.
  
  Attributes:
      config (coref.config.Config): the model's configuration,
          see config.toml for the details
      epochs_trained (int): number of epochs the model has been trained for
      trainable (Dict[str, torch.nn.Module]): trainable submodules with their
          names used as keys
      training (bool): used to toggle train/eval modes
  
  Submodules (in the order of their usage in the pipeline):
      tokenizer (transformers.AutoTokenizer)
      bert (transformers.AutoModel)
      we (WordEncoder)
      rough_scorer (RoughScorer)
      pw (PairwiseEncoder)
      a_scorer (AnaphoricityScorer)
      sp (SpanPredictor)
class_docstr_tok: ["Combines","all","coref","modules","together","to","find","coreferent","spans",".","Attributes",":","config","(","coref.config.Config",")",":","the","model","'s","configuration",",","see","config.toml","for","the","details","epochs_trained","(","int",")",":","number","of","epochs","the","model","has","been","trained","for","trainable","(","Dict","[","str",",","torch.nn.Module","]",")",":","trainable","submodules","with","their","names","used","as","keys","training","(","bool",")",":","used","to","toggle","train\/eval","modes","Submodules","(","in","the","order","of","their","usage","in","the","pipeline",")",":","tokenizer","(","transformers.AutoTokenizer",")","bert","(","transformers.AutoModel",")","we","(","WordEncoder",")","rough_scorer","(","RoughScorer",")","pw","(","PairwiseEncoder",")","a_scorer","(","AnaphoricityScorer",")","sp","(","SpanPredictor",")"]
docstr: Args:
      cluster_ids: tensor of shape [n_words], containing cluster indices
          for each word. Non-gold words have cluster id of zero.
      top_indices: tensor of shape [n_words, n_ants],
          indices of antecedents of each word
      valid_pair_map: boolean tensor of shape [n_words, n_ants],
          whether for pair at [i, j] (i-th word and j-th word)
          j < i is True
  
  Returns:
      tensor of shape [n_words, n_ants + 1] (dummy added),
          containing 1 at position [i, j] if i-th and j-th words corefer.
docstr_tok: ["Args",":","cluster_ids",":","tensor","of","shape","[","n_words","]",",","containing","cluster","indices","for","each","word",".","Non-gold","words","have","cluster","id","of","zero",".","top_indices",":","tensor","of","shape","[","n_words",",","n_ants","]",",","indices","of","antecedents","of","each","word","valid_pair_map",":","boolean","tensor","of","shape","[","n_words",",","n_ants","]",",","whether","for","pair","at","[","i",",","j","]","(","i-th","word","and","j-th","word",")","j","<","i","is","True","Returns",":","tensor","of","shape","[","n_words",",","n_ants","+","1","]","(","dummy","added",")",",","containing","1","at","position","[","i",",","j","]","if","i-th","and","j-th","words","corefer","."]
code: def _get_ground_truth(
      cluster_ids: torch.Tensor,
      top_indices: torch.Tensor,
      valid_pair_map: torch.Tensor,
  ) -> torch.Tensor:
      """
      Args:
          cluster_ids: tensor of shape [n_words], containing cluster indices
              for each word. Non-gold words have cluster id of zero.
          top_indices: tensor of shape [n_words, n_ants],
              indices of antecedents of each word
          valid_pair_map: boolean tensor of shape [n_words, n_ants],
              whether for pair at [i, j] (i-th word and j-th word)
              j < i is True
  
      Returns:
          tensor of shape [n_words, n_ants + 1] (dummy added),
              containing 1 at position [i, j] if i-th and j-th words corefer.
      """
      y = cluster_ids[top_indices] * valid_pair_map  # [n_words, n_ants]
      y[y == 0] = -1  # -1 for non-gold words
      y = utils.add_dummy(y)  # [n_words, n_cands + 1]
      y = y == cluster_ids.unsqueeze(1)  # True if coreferent
      # For all rows with no gold antecedents setting dummy to True
      y[y.sum(dim=1) == 0, 0] = True
      return y.to(torch.float)
  
imports: from datetime import datetime
  import json
  import logging
  import os
  import random
  import re
  from typing import Any, Dict, List, Optional, Set, Tuple
  import numpy
  import toml
  import torch
  import transformers
  from stanza.models.coref import bert, conll, utils
  from stanza.models.coref.anaphoricity_scorer import AnaphoricityScorer
  from stanza.models.coref.cluster_checker import ClusterChecker
  from stanza.models.coref.config import Config
  from stanza.models.coref.const import CorefResult, Doc
  from stanza.models.coref.loss import CorefLoss
  from stanza.models.coref.pairwise_encoder import PairwiseEncoder
  from stanza.models.coref.rough_scorer import RoughScorer
  from stanza.models.coref.span_predictor import SpanPredictor
  from stanza.models.coref.tokenizer_customization import TOKENIZER_FILTERS, TOKENIZER_MAPS
  from stanza.models.coref.utils import GraphNode
  from stanza.models.coref.word_encoder import WordEncoder
  from peft import LoraConfig, get_peft_model, get_peft_model_state_dict, set_peft_model_state_dict
  from stanza.utils.get_tqdm import get_tqdm
label_desc: Use image node_id 18 for calling the CorefModel obj's underlying member method code with example usage: obj._get_ground_truth(cluster_ids, top_indices, valid_pair_map) and returns: y