docstr: Class constructor
  
  Arguments
  ---------
  train_step_name: the name of the training step, for curriculum learning
docstr_tok: ["Class","constructor","Arguments","--","--","--","--","-","train_step_name",":","the","name","of","the","training","step",",","for","curriculum","learning"]
code: def __init__(self, train_step_name, *args, **kwargs):
      """Class constructor
  
      Arguments
      ---------
      train_step_name: the name of the training step, for curriculum learning
      """
      super().__init__(*args, **kwargs)
      self.train_step_name = train_step_name
      self.train_step = next(
          step
          for step in self.hparams.train_steps
          if step["name"] == train_step_name
      )
      self.epoch_counter = self.train_step["epoch_counter"]
      self.mode = TrainMode(train_step.get("mode", TrainMode.NORMAL))
      self.last_attn = None
      self.lr_annealing = getattr(
          self.train_step, "lr_annealing", self.hparams.lr_annealing
      )
      self.phn_key = get_sequence_key(
          key="phn_encoded",
          mode=getattr(self.hparams, "phoneme_sequence_mode", "bos"),
      )
      self.grapheme_key = get_sequence_key(
          key="grapheme_encoded",
          mode=getattr(self.hparams, "grapheme_sequence_mode", "bos"),
      )
      self.beam_searcher = (
          self.hparams.beam_searcher_lm
          if self.hparams.use_language_model
          else self.hparams.beam_searcher
      )
      self.beam_searcher_valid = getattr(
          self.hparams, "beam_searcher_valid", self.beam_searcher
      )
      self.start_epoch = None
  
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 1 to create a new G2PBrain object from inherited base classes: sb with example: obj = G2PBrain(train_step_name)