code: def profile_test(
      record_property: Callable[[str, object], None],
      profiled_metrics: Optional[Dict[str, List[str]]] = None,
  ) -> Callable[[int], None]:
      if not profiled_metrics:
          profiled_metrics = default_metrics
  
      def record(trial_id: int) -> None:
          assert profiled_metrics is not None
          for metric in profiled_metrics:
              metrics = get_profiling_metrics(trial_id, metric)
              if not metrics:
                  print(f"No {metric} metrics collected")
                  continue
  
              for method in profiled_metrics[metric]:
                  metric_key, metric_value = format_xml_property(
                      metric, method, summary_methods[method](metrics)
                  )
                  record_property(metric_key, metric_value)
  
      return record
  
file_path: determined/e2e_tests/tests/experiment/record_profiling.py
imports: import json
  from statistics import mean
  from typing import Callable, Dict, List, Optional, Tuple
  from urllib.parse import urlencode
  from determined.common import api
  from determined.profiler import SysMetricName
  from tests import config
label_desc: Use image node_id 1 for calling a global function with example usage: profile_test(record_property, profiled_metrics) and returns: record