class_docstr: Takes a trained model and makes predictions on new data.
  
  This is a base class which handles some common boilerplate.
  It intentionally has an interface similar to ``Brain`` - these base
  classes handle similar things.
  
  Subclasses of Pretrained should implement the actual logic of how
  the pretrained system runs, and add methods with descriptive names
  (e.g. transcribe_file() for ASR).
  
  Pretrained is a torch.nn.Module so that methods like .to() or .eval() can
  work. Subclasses should provide a suitable forward() implementation: by
  convention, it should be a method that takes a batch of audio signals and
  runs the full model (as applicable).
  
  Arguments
  ---------
  modules : dict of str:torch.nn.Module pairs
      The Torch modules that make up the learned system. These can be treated
      in special ways (put on the right device, frozen, etc.). These are available
      as attributes under ``self.mods``, like self.mods.model(x)
  hparams : dict
      Each key:value pair should consist of a string key and a hyperparameter
      that is used within the overridden methods. These will
      be accessible via an ``hparams`` attribute, using "dot" notation:
      e.g., self.hparams.model(x).
  run_opts : dict
      Options parsed from command line. See ``speechbrain.parse_arguments()``.
      List that are supported here:
       * device
       * data_parallel_count
       * data_parallel_backend
       * distributed_launch
       * distributed_backend
       * jit
       * jit_module_keys
       * compule
       * compile_module_keys
       * compile_mode
       * compile_using_fullgraph
       * compile_using_dynamic_shape_tracing
  freeze_params : bool
      To freeze (requires_grad=False) parameters or not. Normally in inference
      you want to freeze the params. Also calls .eval() on all modules.
class_docstr_tok: ["Takes","a","trained","model","and","makes","predictions","on","new","data",".","This","is","a","base","class","which","handles","some","common","boilerplate",".","It","intentionally","has","an","interface","similar","to","``","Brain","``","-","these","base","classes","handle","similar","things",".","Subclasses","of","Pretrained","should","implement","the","actual","logic","of","how","the","pretrained","system","runs",",","and","add","methods","with","descriptive","names","(","e.g",".","transcribe_file","(",")","for","ASR",")",".","Pretrained","is","a","torch.nn.Module","so","that","methods","like",".to","(",")","or",".eval","(",")","can","work",".","Subclasses","should","provide","a","suitable","forward","(",")","implementation",":","by","convention",",","it","should","be","a","method","that","takes","a","batch","of","audio","signals","and","runs","the","full","model","(","as","applicable",")",".","Arguments","--","--","--","--","-","modules",":","dict","of","str",":","torch.nn.Module","pairs","The","Torch","modules","that","make","up","the","learned","system",".","These","can","be","treated","in","special","ways","(","put","on","the","right","device",",","frozen",",","etc.",")",".","These","are","available","as","attributes","under","``","self.mods","``",",","like","self.mods.model","(","x",")","hparams",":","dict","Each","key",":","value","pair","should","consist","of","a","string","key","and","a","hyperparameter","that","is","used","within","the","overridden","methods",".","These","will","be","accessible","via","an","``","hparams","``","attribute",",","using","``","dot","''","notation",":","e.g.",",","self.hparams.model","(","x",")",".","run_opts",":","dict","Options","parsed","from","command","line",".","See","``","speechbrain.parse_arguments","(",")","``",".","List","that","are","supported","here",":","*","device","*","data_parallel_count","*","data_parallel_backend","*","distributed_launch","*","distributed_backend","*","jit","*","jit_module_keys","*","compule","*","compile_module_keys","*","compile_mode","*","compile_using_fullgraph","*","compile_using_dynamic_shape_tracing","freeze_params",":","bool","To","freeze","(","requires_grad=False",")","parameters","or","not",".","Normally","in","inference","you","want","to","freeze","the","params",".","Also","calls",".eval","(",")","on","all","modules","."]
code: def __init__(
      self,
      modules=None,
      hparams=None,
      run_opts=None,
      freeze_params=True,
  ):
      super().__init__()
      # Arguments passed via the run opts dictionary. Set a limited
      # number of these, since some don't apply to inference.
      run_opt_defaults = {
          "device": "cpu",
          "data_parallel_count": -1,
          "data_parallel_backend": False,
          "distributed_launch": False,
          "distributed_backend": "nccl",
          "jit": False,
          "jit_module_keys": None,
          "compile": False,
          "compile_module_keys": None,
          "compile_mode": "reduce-overhead",
          "compile_using_fullgraph": False,
          "compile_using_dynamic_shape_tracing": False,
      }
      for arg, default in run_opt_defaults.items():
          if run_opts is not None and arg in run_opts:
              setattr(self, arg, run_opts[arg])
          else:
              # If any arg from run_opt_defaults exist in hparams and
              # not in command line args "run_opts"
              if hparams is not None and arg in hparams:
                  setattr(self, arg, hparams[arg])
              else:
                  setattr(self, arg, default)
  
      # Put modules on the right device, accessible with dot notation
      self.mods = torch.nn.ModuleDict(modules)
      for module in self.mods.values():
          if module is not None:
              module.to(self.device)
  
      # Check MODULES_NEEDED and HPARAMS_NEEDED and
      # make hyperparams available with dot notation
      if self.HPARAMS_NEEDED and hparams is None:
          raise ValueError("Need to provide hparams dict.")
      if hparams is not None:
          # Also first check that all required params are found:
          for hp in self.HPARAMS_NEEDED:
              if hp not in hparams:
                  raise ValueError(f"Need hparams['{hp}']")
          self.hparams = SimpleNamespace(**hparams)
  
      # Prepare modules for computation, e.g. jit
      self._prepare_modules(freeze_params)
  
      # Audio normalization
      self.audio_normalizer = hparams.get(
          "audio_normalizer", AudioNormalizer()
      )
  
imports: import logging
  import hashlib
  import sys
  import warnings
  import torch
  import torchaudio
  from types import SimpleNamespace
  from torch.nn import SyncBatchNorm
  from torch.nn import DataParallel
  from hyperpyyaml import load_hyperpyyaml
  from speechbrain.utils.fetching import fetch
  from speechbrain.dataio.preprocess import AudioNormalizer
  from torch.nn.parallel import DistributedDataParallel
  from speechbrain.utils.data_utils import split_path
  from speechbrain.utils.distributed import run_on_main
  from speechbrain.dataio.batch import PaddedBatch, PaddedData
  from speechbrain.utils.data_pipeline import DataPipeline
  from speechbrain.utils.superpowers import import_from_path
label_desc: Use image node_id 1 to create a new Pretrained object from inherited base classes: torch.nn with example: obj = Pretrained(modules, hparams, run_opts, freeze_params)