docstr: Saves text predictions aligned with lables (a sample, for progress
  tracking)
docstr_tok: ["Saves","text","predictions","aligned","with","lables","(","a","sample",",","for","progress","tracking",")"]
code: def _save_text_alignments(self):
      """Saves text predictions aligned with lables (a sample, for progress
      tracking)"""
      if not self.hparams.enable_metrics:
          return
      last_batch_sample = self.per_metrics.scores[
          -self.hparams.eval_prediction_sample_size :
      ]
      metrics_by_wer = sorted(
          self.per_metrics.scores,
          key=lambda item: item["WER"],
          reverse=True,
      )
      worst_sample = metrics_by_wer[
          : self.hparams.eval_prediction_sample_size
      ]
      sample_size = min(
          self.hparams.eval_prediction_sample_size,
          len(self.per_metrics.scores),
      )
      random_sample = np.random.choice(
          self.per_metrics.scores, sample_size, replace=False
      )
      text_alignment_samples = {
          "last_batch": last_batch_sample,
          "worst": worst_sample,
          "random": random_sample,
      }
      prefix = self.train_step["name"]
      for key, sample in text_alignment_samples.items():
          self._save_text_alignment(
              tag=f"valid/{prefix}_{key}", metrics_sample=sample
          )
  
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 23 for calling the G2PBrain obj's underlying member method code with example usage: obj._save_text_alignments() without return types