code: def get_yaml_var(hparam_file):
      """Extracts from the input yaml file (hparams_file) the list of variables that
      should be used in the script file.
  
      Arguments
      ---------
      hparam_file : path
          Path of the yaml file containing the hyperparameters.
  
      Returns
      -------
      var_list: list
          list of the variables declared in the yaml file (sub-variables are not
          included).
      """
      var_lst = []
      with open(hparam_file) as f:
          for line in f:
              # Avoid empty lists or comments - skip pretrainer definitions
              if (
                  len(line) <= 1
                  or line.startswith("#")
                  or "speechbrain.utils.parameter_transfer.Pretrainer"
                  in line
              ):
                  continue
  
              # Remove trailing characters
              line = line.rstrip()
  
              # Check for variables (e.g., 'key:' or '!ref')
              if line.find(":") != -1 or line.find("!ref") != -1:
                  var_name = line[: line.find(":")]
                  # The variables to check are like "key:" (we do not need to check
                  # subvariavles as " key:")
                  if not (
                      var_name[0] == " "
                      or var_name[0] == "\t"
                      or "!!" in line
                      or "!apply" in line
                  ):
                      var_lst.append(var_name)
                  # Check for the reference pattern
                  # note: output_folder: !ref results/<experiment_name>/<seed> pattern
                  if line.find("!ref") != -1:
                      # Check for 'annotation_list_to_check: [!ref <train_csv>, !ref <valid_csv>]' pattern
                      for subline in line.split("<"):
                          sub_var = subline[: subline.find(">")]
                          # Check for 'models[generator]' pattern (dictionary reference)
                          dict_pos = sub_var.find("[")
                          if dict_pos != -1:
                              sub_var = sub_var[:dict_pos]
                          # Remove variables already used in yaml
                          if sub_var in var_lst:
                              var_lst.remove(sub_var)
      return var_lst
  
imports: import os
  import re
  from speechbrain.core import run_opt_defaults
label_desc: Use image node_id 1 for calling a global function with example usage: get_yaml_var(hparam_file) and returns: var_lst