docstr: Produces a sample in inference mode.
  This is called when producing samples.
  
  Arguments
  ---------
  name: str
      the name of the saved audio folder
  epoch: int or str
      the epoch number (used in file path calculations)
      or "test" for test stage
docstr_tok: ["Produces","a","sample","in","inference","mode",".","This","is","called","when","producing","samples",".","Arguments","--","--","--","--","-","name",":","str","the","name","of","the","saved","audio","folder","epoch",":","int","or","str","the","epoch","number","(","used","in","file","path","calculations",")","or","``","test","''","for","test","stage"]
code: def run_inference_sample(self, name, epoch):
      """Produces a sample in inference mode.
      This is called when producing samples.
  
      Arguments
      ---------
      name: str
          the name of the saved audio folder
      epoch: int or str
          the epoch number (used in file path calculations)
          or "test" for test stage
      """
      with torch.no_grad():
          if self.last_batch is None:
              return
          x, y = self.last_batch
  
          # Preparing model for inference by removing weight norm
          inference_generator = copy.deepcopy(self.hparams.generator)
          inference_generator.remove_weight_norm()
          if inference_generator.duration_predictor:
              x = torch.unique_consecutive(x, dim=1)
          sig_out = inference_generator.inference(x)
          spec_out = self.hparams.mel_spectogram(
              audio=sig_out.squeeze(0).cpu()
          )
      if self.hparams.use_tensorboard:
          self.tensorboard_logger.log_audio(
              f"{name}/audio_target",
              y.squeeze(0),
              self.hparams.sample_rate,
          )
          self.tensorboard_logger.log_audio(
              f"{name}/audio_pred",
              sig_out.squeeze(0),
              self.hparams.sample_rate,
          )
          self.tensorboard_logger.log_figure(f"{name}/mel_target", x)
          self.tensorboard_logger.log_figure(
              f"{name}/mel_pred", spec_out
          )
      else:
          # folder name is the current epoch for validation and "test" for test
          folder = (
              self.hparams.epoch_counter.current
              if name == "Valid"
              else "test"
          )
          self.save_audio("target", y.squeeze(0), folder)
          self.save_audio("synthesized", sig_out.squeeze(0), folder)
  
imports: import sys
  import copy
  import random
  import pathlib
  from hyperpyyaml import load_hyperpyyaml
  import speechbrain
  from speechbrain.utils.data_utils import scalarize
  import torch
  import torchaudio
  import numpy
label_desc: Use image node_id 8 for calling the HifiGanBrain obj's underlying member method code with example usage: obj.run_inference_sample(name, epoch) without return types