code: def test_searcher_metric(self):
      train_x, train_y, val_x, val_y = get_np_input()
      data = (train_x, train_y)
      val_data = (val_x, val_y)
  
      # test metric name is returned and max mode can be stopped
      searcher = prepare_searcher(
          data=data,
          validation_data=val_data,
          name="test_searcher_metric_name",
          metric="mse",
          metric_mode="min",
          search_space=create_simple_search_space(),
          stop=create_stop(float("inf")),
      )
      analysis = searcher.run()
      sorted_results = list(
          map(
              lambda x: x.last_result["mse"],
              RayTuneSearchEngine._get_sorted_trials(
                  analysis.trials, metric="mse", mode="min"
              ),
          )
      )
  
      # assert metric name is reported
      assert "mse" in analysis.trials[0].last_result.keys()
      # assert _get_sorted_trials get increasing result
      assert all(
          sorted_results[i] <= sorted_results[i + 1]
          for i in range(len(sorted_results) - 1)
      )
      # assert _get_best_result get minimum result
      assert (
          RayTuneSearchEngine._get_best_result(
              analysis.trials, metric="mse", mode="min"
          )["mse"]
          == sorted_results[0]
      )
      assert all(
          analysis.trials[i].last_result["mse"]
          >= analysis.trials[i].last_result["best_mse"]
          for i in range(len(sorted_results))
      )
      # assert the trail stop at once since mse has mode of 'min'
      assert (
          analysis.trials[0].last_result["iterations_since_restore"]
          == 1
      )
  
      # max mode metric with stop
      searcher = prepare_searcher(
          data=data,
          validation_data=val_data,
          name="test_searcher_metric_name",
          metric="r2",
          metric_mode="max",
          search_space=create_simple_search_space(),
          stop=create_stop(0),
      )  # stop at once
      analysis = searcher.run()
      sorted_results = list(
          map(
              lambda x: x.last_result["r2"],
              RayTuneSearchEngine._get_sorted_trials(
                  analysis.trials, metric="r2", mode="max"
              ),
          )
      )
  
      # assert metric name is reported
      assert "r2" in analysis.trials[0].last_result.keys()
      # assert _get_sorted_trials get decreasing result
      assert all(
          sorted_results[i] >= sorted_results[i + 1]
          for i in range(len(sorted_results) - 1)
      )
      # assert _get_best_result get maximum result
      assert (
          RayTuneSearchEngine._get_best_result(
              analysis.trials, metric="r2", mode="max"
          )["r2"]
          == sorted_results[0]
      )
      assert all(
          analysis.trials[i].last_result["r2"]
          <= analysis.trials[i].last_result["best_r2"]
          for i in range(len(sorted_results))
      )
      # assert the trail stop at once since mse has mode of 'max'
      assert (
          analysis.trials[0].last_result["iterations_since_restore"]
          == 1
      )
  
      # test min mode metric without stop
      searcher = prepare_searcher(
          data=data,
          validation_data=val_data,
          name="test_searcher_metric_name",
          metric="mae",
          metric_mode="min",
          search_space=create_simple_search_space(),
          stop=create_stop(0),
      )  # never stop by metric
      analysis = searcher.run()
      sorted_results = list(
          map(
              lambda x: x.last_result["mae"],
              RayTuneSearchEngine._get_sorted_trials(
                  analysis.trials, metric="mae", mode="min"
              ),
          )
      )
  
      # assert metric name is reported
      assert "mae" in analysis.trials[0].last_result.keys()
      # assert _get_sorted_trials get increasing result
      assert all(
          sorted_results[i] <= sorted_results[i + 1]
          for i in range(len(sorted_results) - 1)
      )
      # assert _get_best_result get minimum result
      assert (
          RayTuneSearchEngine._get_best_result(
              analysis.trials, metric="mae", mode="min"
          )["mae"]
          == sorted_results[0]
      )
      assert all(
          analysis.trials[i].last_result["mae"]
          >= analysis.trials[i].last_result["best_mae"]
          for i in range(len(sorted_results))
      )
      # assert the trail stop at once since mse has mode of 'min'
      assert (
          analysis.trials[0].last_result["iterations_since_restore"]
          == 20
      )
  
imports: from bigdl.orca.test_zoo_utils import ZooTestCase
  from bigdl.orca.automl.search import SearchEngineFactory
  from bigdl.orca.automl.search.ray_tune import RayTuneSearchEngine
  from bigdl.orca.automl.model.base_pytorch_model import PytorchModelBuilder
  import torch
  import torch.nn
  from bigdl.orca.automl import hp
  import numpy
  from bigdl.orca import init_orca_context, stop_orca_context
label_desc: Use image node_id 4 for calling the TestRayTuneSearchEngine obj's underlying member method code with example usage: obj.test_searcher_metric() without return types