class_docstr: A convenience context manager that makes it possible to conditionally
  enable hyperparameter optimization for a recipe.
  
  Arguments
  ---------
  reporter_args: list
      arguments to the reporter class
  reporter_kwargs: dict
      keyword arguments to the reporter class
  
  Example
  -------
  >>> ctx = HyperparameterOptimizationContext(
  ...     reporter_args=[],
  ...     reporter_kwargs={"objective_key": "error"}
  ... )
docstr: A version of speechbrain.parse_arguments enhanced for hyperparameter optimization.
  
  If a parameter named 'hpopt' is provided, hyperparameter
  optimization and reporting will be enabled.
  
  If the parameter value corresponds to a filename, it will
  be read as a hyperpyaml file, and the contents will be added
  to "overrides". This is useful for cases where the values of
  certain hyperparameters are different during hyperparameter
  optimization vs during full training (e.g. number of epochs, saving
  files, etc)
  
  Arguments
  ---------
  arg_list: list
      a list of arguments
  pass_hpopt_args: enumerable
      forces arguments that are normally suppressed and only used
      for hyperparameter optimization to be passed into overrides
  pass_trial_id: bool
      whether the "trial_id" argument is passed through (enabled by default)
  
  
  Returns
  -------
  param_file : str
      The location of the parameters file.
  run_opts : dict
      Run options, such as distributed, device, etc.
  overrides : dict
      The overrides to pass to ``load_hyperpyyaml``.
  
  Example
  -------
  >>> ctx = HyperparameterOptimizationContext()
  >>> arg_list = ["hparams.yaml", "--x", "1", "--y", "2"]
  >>> hparams_file, run_opts, overrides = ctx.parse_arguments(arg_list)
  >>> print(f"File: {hparams_file}, Overrides: {overrides}")
  File: hparams.yaml, Overrides: {'x': 1, 'y': 2}
docstr_tok: ["A","version","of","speechbrain.parse_arguments","enhanced","for","hyperparameter","optimization",".","If","a","parameter","named","'hpopt","'","is","provided",",","hyperparameter","optimization","and","reporting","will","be","enabled",".","If","the","parameter","value","corresponds","to","a","filename",",","it","will","be","read","as","a","hyperpyaml","file",",","and","the","contents","will","be","added","to","``","overrides","''",".","This","is","useful","for","cases","where","the","values","of","certain","hyperparameters","are","different","during","hyperparameter","optimization","vs","during","full","training","(","e.g",".","number","of","epochs",",","saving","files",",","etc",")","Arguments","--","--","--","--","-","arg_list",":","list","a","list","of","arguments","pass_hpopt_args",":","enumerable","forces","arguments","that","are","normally","suppressed","and","only","used","for","hyperparameter","optimization","to","be","passed","into","overrides","pass_trial_id",":","bool","whether","the","``","trial_id","''","argument","is","passed","through","(","enabled","by","default",")","Returns","--","--","--","-","param_file",":","str","The","location","of","the","parameters","file",".","run_opts",":","dict","Run","options",",","such","as","distributed",",","device",",","etc",".","overrides",":","dict","The","overrides","to","pass","to","``","load_hyperpyyaml","``",".","Example","--","--","--","-",">",">",">","ctx","=","HyperparameterOptimizationContext","(",")",">",">",">","arg_list","=","[","``","hparams.yaml","''",",","``","--","x","''",",","``","1","''",",","``","--","y","''",",","``","2","''","]",">",">",">","hparams_file",",","run_opts",",","overrides","=","ctx.parse_arguments","(","arg_list",")",">",">",">","print","(","f","''","File",":","{","hparams_file","}",",","Overrides",":","{","overrides","}","''",")","File",":","hparams.yaml",",","Overrides",":","{","'","x","'",":","1",",","'","y","'",":","2","}"]
code: def parse_arguments(
      self, arg_list, pass_hpopt_args=None, pass_trial_id=True
  ):
      """A version of speechbrain.parse_arguments enhanced for hyperparameter optimization.
  
      If a parameter named 'hpopt' is provided, hyperparameter
      optimization and reporting will be enabled.
  
      If the parameter value corresponds to a filename, it will
      be read as a hyperpyaml file, and the contents will be added
      to "overrides". This is useful for cases where the values of
      certain hyperparameters are different during hyperparameter
      optimization vs during full training (e.g. number of epochs, saving
      files, etc)
  
      Arguments
      ---------
      arg_list: list
          a list of arguments
      pass_hpopt_args: enumerable
          forces arguments that are normally suppressed and only used
          for hyperparameter optimization to be passed into overrides
      pass_trial_id: bool
          whether the "trial_id" argument is passed through (enabled by default)
  
  
      Returns
      -------
      param_file : str
          The location of the parameters file.
      run_opts : dict
          Run options, such as distributed, device, etc.
      overrides : dict
          The overrides to pass to ``load_hyperpyyaml``.
  
      Example
      -------
      >>> ctx = HyperparameterOptimizationContext()
      >>> arg_list = ["hparams.yaml", "--x", "1", "--y", "2"]
      >>> hparams_file, run_opts, overrides = ctx.parse_arguments(arg_list)
      >>> print(f"File: {hparams_file}, Overrides: {overrides}")
      File: hparams.yaml, Overrides: {'x': 1, 'y': 2}
      """
      if pass_hpopt_args is None:
          pass_hpopt_args = []
      pass_hpopt_args = set(pass_hpopt_args)
      hparams_file, run_opts, overrides_yaml = sb.parse_arguments(
          arg_list
      )
      overrides = (
          load_hyperpyyaml(overrides_yaml) if overrides_yaml else {}
      )
      hpopt = overrides.get(KEY_HPOPT, False)
      hpopt_mode = overrides.get(KEY_HPOPT_MODE) or DEFAULT_REPORTER
      if hpopt:
          self.enabled = True
          self.reporter = get_reporter(
              hpopt_mode, *self.reporter_args, **self.reporter_kwargs
          )
          if isinstance(hpopt, str) and os.path.exists(hpopt):
              with open(hpopt) as hpopt_file:
                  trial_id = get_trial_id()
                  hpopt_overrides = load_hyperpyyaml(
                      hpopt_file,
                      overrides={"trial_id": trial_id},
                      overrides_must_match=False,
                  )
                  overrides = dict(hpopt_overrides, **overrides)
                  keys = list(HPOPT_KEYS)
                  if not pass_trial_id:
                      keys.append(KEY_TRIAL_ID)
                  for key in keys:
                      if (
                          key in overrides
                          and key not in pass_hpopt_args
                      ):
                          del overrides[key]
      return hparams_file, run_opts, overrides
  
imports: import importlib
  import logging
  import json
  import os
  import speechbrain
  import sys
  from datetime import datetime
  from hyperpyyaml import load_hyperpyyaml
label_desc: Use image node_id 2 for calling the HyperparameterOptimizationContext obj's underlying member method code with example usage: obj.parse_arguments(arg_list, pass_hpopt_args, pass_trial_id) and returns: hparams_file,  run_opts,  overrides