code: def add_new_params_to_records(new_params, records=None):
      """For a list of records (each being a `dict`) and a set of parameters
      each having a list of potential values, it expands each record in all possible
      ways based on all possible values for each param in ``new_params``.
      Then it returns all possible augmented records in a list.
  
      Parameters
      ----------
      new_params : `dict` {`str`: `list`}
          A dictionary with keys representing (new) variables and values for each
          key being the possible values for that variable.
      records : `list` [`dict`] or None, default None
          List of existing records which are to be augmented with all possible
          combinations of the new variables. If None, it is assigned to ``[{}]``
          which means we start from an empty record.
  
      Returns
      -------
      expanded_records : `list` [`dict`]
          The resulting list of augmented records.
      """
      if records is None:
          records = [{}]
  
      def add_new_param_values(name, values, records):
          # `records` is a list and it is copied so that its not altered
          # Note that `deepcopy` is not possible for lists
          # Therefore inside the for loop we copy each param (`dict`)
          records = records.copy()
          expanded_records = []
          for param in records:
              for v in values:
                  # Copies to avoid over-write
                  expanded_param = param.copy()
                  expanded_param.update({name: v})
                  expanded_records.append(expanded_param)
          return expanded_records
  
      expanded_records = records.copy()
      for name, values in new_params.items():
          expanded_records = add_new_param_values(
              name=name, values=values, records=expanded_records
          )
  
      return expanded_records
  
file_path: greykite/greykite/detection/detector/ad_utils.py
imports: from functools import reduce
  import pandas
  from greykite.common.constants import ANOMALY_COL
  from greykite.common.constants import END_TIME_COL
  from greykite.common.constants import START_TIME_COL
  from greykite.common.constants import TIME_COL
  from greykite.common.features.outlier import ZScoreOutlierDetector
  from greykite.common.logging import LoggingLevelEnum
  from greykite.common.logging import log_message
  from greykite.detection.detector.constants import Z_SCORE_CUTOFF
label_desc: Use image node_id 3 for calling a global function with example usage: add_new_params_to_records(new_params, records) and returns: expanded_records, expanded_records