class_docstr: This is a classification model that selects the best heteronym option out of possible dictionary entries.
  Supports only heteronyms, no OOV.
code: def _disambiguate(
      self,
      manifest: str,
      batch_size: int,
      num_workers: int = 0,
      grapheme_field="text_graphemes",
  ):
      # store predictions for all queries in a single list
      all_preds = []
      mode = self.training
      try:
          device = "cuda" if torch.cuda.is_available() else "cpu"
          # Switch model to evaluation mode
          self.eval()
          self.to(device)
          infer_datalayer = self._setup_infer_dataloader(
              manifest,
              grapheme_field=grapheme_field,
              batch_size=batch_size,
              num_workers=num_workers,
          )
  
          for batch in infer_datalayer:
              subtokens_mask = batch["subtokens_mask"]
              batch = {
                  "input_ids": batch["input_ids"].to(device),
                  "attention_mask": batch["attention_mask"].to(device),
              }
              _, logits = self.make_step(batch)
  
              preds = tensor2list(
                  torch.argmax(logits, axis=-1)[subtokens_mask > 0]
              )
              # preds are flatten for all the samples, we need to separate predictions per sample
              preds_num = [
                  len([p_ for p_ in p if p_ == 1])
                  for p in tensor2list(subtokens_mask)
              ]
  
              last_idx = 0
              for num in preds_num:
                  preds_ = preds[last_idx : last_idx + num]
                  preds_ = [self.idx_to_wordid[p] for p in preds_]
                  all_preds.append(preds_)
                  last_idx += num
      finally:
          # set mode back to its original value
          self.train(mode=mode)
      return all_preds
  
imports: import json
  import os
  from typing import List, Optional
  import torch
  from hydra.utils import instantiate
  from omegaconf import DictConfig
  from pytorch_lightning import Trainer
  from nemo.collections.common.losses import CrossEntropyLoss
  from nemo.collections.nlp.metrics.classification_report import ClassificationReport
  from nemo.collections.nlp.modules.common import TokenClassifier
  from nemo.collections.nlp.parts.utils_funcs import tensor2list
  from nemo.collections.tts.g2p.data.heteronym_classification import HeteronymClassificationDataset
  from nemo.collections.tts.g2p.utils import get_heteronym_spans, get_wordid_to_phonemes, read_wordids
  from nemo.core.classes.common import PretrainedModelInfo
  from nemo.utils import logging
label_desc: Use image node_id 13 for calling the HeteronymClassificationModel obj's underlying member method code with example usage: obj._disambiguate(manifest, batch_size, num_workers, grapheme_field) and returns: all_preds