docstr: loads the best-performing checkpoint, based on stored metrics.
  
  Arguments
  ---------
  max_key : str
      Key to use for finding best checkpoint (higher is better).
      By default, passed to ``self.checkpointer.recover_if_possible()``.
  min_key : str
      Key to use for finding best checkpoint (lower is better).
      By default, passed to ``self.checkpointer.recover_if_possible()``.
docstr_tok: ["loads","the","best-performing","checkpoint",",","based","on","stored","metrics",".","Arguments","--","--","--","--","-","max_key",":","str","Key","to","use","for","finding","best","checkpoint","(","higher","is","better",")",".","By","default",",","passed","to","``","self.checkpointer.recover_if_possible","(",")","``",".","min_key",":","str","Key","to","use","for","finding","best","checkpoint","(","lower","is","better",")",".","By","default",",","passed","to","``","self.checkpointer.recover_if_possible","(",")","``","."]
code: def _recover_checkpoint(self, min_key=None, max_key=None):
      """loads the best-performing checkpoint, based on stored metrics.
  
      Arguments
      ---------
      max_key : str
          Key to use for finding best checkpoint (higher is better).
          By default, passed to ``self.checkpointer.recover_if_possible()``.
      min_key : str
          Key to use for finding best checkpoint (lower is better).
          By default, passed to ``self.checkpointer.recover_if_possible()``.
      """
      if self.checkpointer is not None:
          step = self.train_step["name"]
          logger.info(
              f"Attempting to restore checkpoint for step {step}"
          )
          result = self.checkpointer.recover_if_possible(
              min_key=min_key,
              max_key=max_key,
              ckpt_predicate=(
                  lambda ckpt: ckpt.meta.get("step") == step
              ),
          )
          if result is None:
              logger.info(
                  "No checkpoint fount for step %s, "
                  "attempting to recover any checkpoint",
                  step,
              )
              result = self.checkpointer.recover_if_possible(
                  min_key=min_key,
                  max_key=max_key,
              )
              if result:
                  logger.info(
                      "Recovered checkpoint with metadata %s",
                      result.meta,
                  )
              else:
                  logger.info("No checkpoint found")
  
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 4 for calling the G2PBrain obj's underlying member method code with example usage: obj._recover_checkpoint(min_key, max_key) without return types