class_docstr: The G2P model evaluation wrapper
  
  Arguments
  ---------
  hparams: dict
      the dictionary from a parsed hyperparameter file
  device: str
      the device identifier
  model_state: dict
      a pre-loaded model state for a "warm start" if applicable
      - could be useful if hyperparameters have changed, but
      the same model can be reused from one run to the next
docstr: Evaluates the G2P model
  
  Arguments
  ---------
  batch: PaddedBatch
      A single batch of data, same as the kind of batch used
      for G2P training
docstr_tok: ["Evaluates","the","G2P","model","Arguments","--","--","--","--","-","batch",":","PaddedBatch","A","single","batch","of","data",",","same","as","the","kind","of","batch","used","for","G2P","training"]
code: def evaluate_batch(self, batch):
      """
      Evaluates the G2P model
  
      Arguments
      ---------
      batch: PaddedBatch
          A single batch of data, same as the kind of batch used
          for G2P training
      """
      batch = batch.to(self.device)
      grapheme_encoded = getattr(batch, self.grapheme_key)
      if self.hparams.eval_mode == "sentence":
          hyps, scores = self._get_phonemes(
              grapheme_encoded, char=batch.char
          )
      elif self.hparams.eval_mode == "word":
          hyps, scores = self._get_phonemes_wordwise(
              batch.grapheme_encoded
          )
      else:
          raise ValueError(
              f"unsupported eval_mode {self.hparams.eval_mode}"
          )
  
      ids = batch.sample_id
  
      phns, phn_lens = batch.phn_encoded
  
      self.per_metrics.append(
          ids,
          hyps,
          phns,
          None,
          phn_lens,
          self.hparams.out_phoneme_decoder,
      )
  
imports: from hyperpyyaml import load_hyperpyyaml
  from speechbrain.dataio.batch import PaddedBatch
  from speechbrain.lobes.models.g2p.dataio import get_sequence_key
  from speechbrain.utils import hpopt
  from speechbrain.wordemb.util import expand_to_chars
  from train import dataio_prep, load_dependencies
  from types import SimpleNamespace
  from tqdm.auto import tqdm
  import math
  import itertools
  import speechbrain
  import torch
  import sys
  import logging
label_desc: Use image node_id 3 for calling the G2PEvaluator obj's underlying member method code with example usage: obj.evaluate_batch(batch) without return types