docstr: Forward computations from the char batches to the output probabilities.
docstr_tok: ["Forward","computations","from","the","char","batches","to","the","output","probabilities","."]
code: def compute_forward(self, batch, stage):
      """Forward computations from the char batches to the output probabilities."""
      batch = batch.to(self.device)
  
      # Get graphemes or phonemes
      graphemes, grapheme_lens = getattr(batch, self.grapheme_key)
      phn_encoded = getattr(batch, self.phn_key)
      word_emb = None
      # Use word embeddings (if applicable)
      if self.hparams.use_word_emb:
          word_emb = self.modules.word_emb.batch_embeddings(batch.char)
          char_word_emb = expand_to_chars(
              emb=word_emb,
              seq=graphemes,
              seq_len=grapheme_lens,
              word_separator=self.grapheme_word_separator_idx,
          )
      else:
          word_emb, char_word_emb = None, None
  
      # Forward pass through the model
      p_seq, char_lens, encoder_out, attn = self.modules["model"](
          grapheme_encoded=(graphemes.detach(), grapheme_lens),
          phn_encoded=phn_encoded,
          word_emb=char_word_emb,
      )
  
      self.last_attn = attn
  
      hyps = None
  
      # Apply CTC, if applicable
      ctc_logprobs = None
      if stage == sb.Stage.TRAIN and self.is_ctc_active(stage):
          # Output layer for ctc log-probabilities
          ctc_logits = self.modules.ctc_lin(encoder_out)
          ctc_logprobs = self.hparams.log_softmax(ctc_logits)
  
      if stage != sb.Stage.TRAIN and self.hparams.enable_metrics:
          beam_searcher = (
              self.beam_searcher_valid
              if stage == sb.Stage.VALID
              else self.beam_searcher
          )
  
          hyps, _, _, _ = beam_searcher(encoder_out, char_lens)
  
      return G2PPredictions(p_seq, char_lens, hyps, ctc_logprobs, attn)
  
imports: from speechbrain.dataio.dataset import FilteredSortedDynamicItemDataset, DynamicItemDataset
  from speechbrain.dataio.sampler import BalancingDataSampler
  from speechbrain.utils.data_utils import undo_padding
  import datasets
  import logging
  import os
  import random
  import speechbrain
  import sys
  from enum import Enum
  from collections import namedtuple
  from hyperpyyaml import load_hyperpyyaml
  from functools import partial
  from speechbrain.utils.distributed import run_on_main
  from speechbrain.utils.pretrained import save_for_pretrained
  from speechbrain.lobes.models.g2p.dataio import enable_eos_bos, grapheme_pipeline, phoneme_pipeline, tokenizer_encode_pipeline, add_bos_eos, get_sequence_key, phonemes_to_label
  from speechbrain.dataio.wer import print_alignments
  from speechbrain.wordemb.util import expand_to_chars
  from io import StringIO
  from speechbrain.utils import hpopt
  import numpy
label_desc: Use image node_id 5 for calling the G2PBrain obj's underlying member method code with example usage: obj.compute_forward(batch, stage) and returns: G2PPredictions