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: Loads pretrained weights of modules saved in a file located at path.
  If path is None, the last saved model with current configuration
  in save_dir is loaded.
  Assumes files are named like {configuration}_(e{epoch}_{time})*.pt.
docstr_tok: ["Loads","pretrained","weights","of","modules","saved","in","a","file","located","at","path",".","If","path","is","None",",","the","last","saved","model","with","current","configuration","in","save_dir","is","loaded",".","Assumes","files","are","named","like","{","configuration","}","_","(","e","{","epoch","}","_","{","time","}",")","*",".pt","."]
code: def load_weights(
      self,
      path: Optional[str] = None,
      ignore: Optional[Set[str]] = None,
      map_location: Optional[str] = None,
      noexception: bool = False,
  ) -> None:
      """
      Loads pretrained weights of modules saved in a file located at path.
      If path is None, the last saved model with current configuration
      in save_dir is loaded.
      Assumes files are named like {configuration}_(e{epoch}_{time})*.pt.
      """
      if path is None:
          pattern = rf"{self.config.section}_\(e(\d+)_[^()]*\).*\.pt"
          files = []
          for f in os.listdir(self.config.save_dir):
              match_obj = re.match(pattern, f)
              if match_obj:
                  files.append((int(match_obj.group(1)), f))
          if not files:
              if noexception:
                  logger.debug(
                      "No weights have been loaded", flush=True
                  )
                  return
              raise OSError(
                  f"No weights found in {self.config.save_dir}!"
              )
          _, path = sorted(files)[-1]
          path = os.path.join(self.config.save_dir, path)
  
      if map_location is None:
          map_location = self.config.device
      logger.debug(f"Loading from {path}...")
      state_dicts = torch.load(path, map_location=map_location)
      self.epochs_trained = state_dicts.pop("epochs_trained", 0)
      # just ignore a config in the model, since we should already have one
      # TODO: some config elements may be fixed parameters of the model,
      # such as the dimensions of the head,
      # so we would want to use the ones from the config even if the
      # user created a weird shaped model
      config = state_dicts.pop("config", {})
      self.load_state_dicts(state_dicts, ignore)
  
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 5 for calling the CorefModel obj's underlying member method code with example usage: obj.load_weights(path, ignore, map_location, noexception) without return types