code: def check_metrics(self, nni_source_dir, **kwargs):
      expected_result_file = kwargs.get(
          "expected_result_file", "expected_metrics.json"
      )
      with open(
          osp.join(
              nni_source_dir,
              "test",
              "training_service",
              "config",
              "metrics_test",
              expected_result_file,
          ),
          "r",
      ) as f:
          expected_metrics = json.load(f)
      print("expected metrics:", expected_metrics)
      metrics = requests.get(METRICS_URL).json()
      print("RAW METRICS:", json.dumps(metrics, indent=4))
      intermediate_result, final_result = self.get_metric_results(
          metrics
      )
  
      assert intermediate_result and final_result
      for trialjob_id in intermediate_result:
          trial_final_result = final_result[trialjob_id]
          trial_intermediate_result = intermediate_result[trialjob_id]
          print("intermediate result:", trial_intermediate_result)
          print("final result:", trial_final_result)
          assert (
              len(trial_final_result) == 1
          ), "there should be 1 final result"
          assert (
              trial_final_result[0] == expected_metrics["final_result"]
          )
          # encode dict/number into json string to compare them in set
          assert set(
              [
                  json.dumps(x, sort_keys=True)
                  for x in trial_intermediate_result
              ]
          ) == set(
              [
                  json.dumps(x, sort_keys=True)
                  for x in expected_metrics["intermediate_result"]
              ]
          )
  
imports: import os.path
  from os import remove
  import subprocess
  import json
  import requests
  from nni.experiment import Experiment
  from nni.tools.nnictl.updater import load_imported_data
  from utils import METRICS_URL, GET_IMPORTED_DATA_URL
label_desc: Use image node_id 2 for calling the MetricsValidator obj's underlying member method code with example usage: obj.check_metrics(nni_source_dir) without return types