code: def ax_evaluate_params(
      params_list: List[Dict],
      fixed_params: Dict,
      eval_fn: Callable,
      parse_params_fn: Optional[Callable] = None,
      num_seeds: int = 10,
      num_proc: int = 20,
  ) -> List[Dict[str, Tuple[float, float]]]:
      """
      Evaluate a single set of hyperparameters for Ax search.
  
      Args:
          params_list: A list of hyperparameter configs to evaluate.
          fixed_params: A dictionary of hyperparameters that are held fixed between evaluations.
          eval_fn: Evaluation function that returns a dictionary of metric values.
          parse_params_fn: A optional function applied to the hyperparameter dictionary to parse some elements. Can be useful
              if the best representation for Ax doesn't match the format accepted by the eval_fn.
          num_seeds: Number of random seeds among which the metrics are averaged.
          num_proc: Number of processes to run in parallel.
      Returns:
          A list of average evaluation metrics (one per config)
      """
      # create a list of full hyperparameter configurations to be evaluated
      params_with_seed_list = []
      for params in params_list:
          for s in range(num_seeds):
              params_s = copy.deepcopy(params)
              params_s.update(fixed_params)
              params_s["seed"] = s
              if parse_params_fn is not None:
                  params_s = parse_params_fn(params_s)
              params_with_seed_list.append(params_s)
  
      # evaluate metrics in parallel using multiprocessing
      if num_proc > 1:
          with mp.get_context("spawn").Pool(
              min(len(params_with_seed_list), num_proc)
          ) as p:
              metrics = p.map(eval_fn, params_with_seed_list)
      else:
          metrics = list(map(eval_fn, params_with_seed_list))
  
      # calculate the average metrics across different seeds
      avg_metrics = []
      num_params = len(params_list)
      for i in range(num_params):
          avg_metrics.append(
              {
                  k: (
                      np.mean(
                          [
                              m[k]
                              for m in metrics[
                                  i * num_seeds : (i + 1) * num_seeds
                              ]
                          ]
                      ),
                      np.std(
                          [
                              m[k]
                              for m in metrics[
                                  i * num_seeds : (i + 1) * num_seeds
                              ]
                          ]
                      ),
                  )
                  for k in metrics[0].keys()
              }
          )
      return avg_metrics
  
file_path: ReAgent/reagent/scripts/hparam_tuning.py
imports: import logging
  import copy
  import json
  import os
  from typing import Any, Callable, Dict, List, Optional, Tuple
  import numpy
  import torch.multiprocessing
  from ax.service.ax_client import AxClient
label_desc: Use image node_id 1 for calling a global function with example usage: ax_evaluate_params(params_list, fixed_params, eval_fn, parse_params_fn, num_seeds, num_proc) and returns: avg_metrics