code: def model_selection_trails_workloads(params: dict, args: Namespace):
      """
      Run filtering (explore N models) and refinement phase (refine K models) for benchmarking latency.
      """
  
      begin_time = time.time()
      mini_batch_data = json.loads(params["mini_batch"])
      n = int(params["n"])
      k = int(params["k"])
  
      # 1. launch cache service, for both train and valid.
      # todo: use real data table or others
      columns = list(mini_batch_data[0].keys())
      requests.post(
          args.cache_svc_url,
          json={
              "columns": columns,
              "name_space": "train",
              "table_name": "dummy",
              "batch_size": len(mini_batch_data),
          },
      )
      requests.post(
          args.cache_svc_url,
          json={
              "columns": columns,
              "name_space": "valid",
              "table_name": "dummy",
              "batch_size": len(mini_batch_data),
          },
      )
  
      from src.logger import logger
  
      logger.info(
          f"begin run model_selection_trails_workloads CPU + GPU, explore N={n} and K={k}"
      )
  
      from src.eva_engine.run_ms import RunModelSelection
  
      # 2. filtering
      dataloader = generate_dataloader(
          mini_batch_data=mini_batch_data, args=args
      )
      rms = RunModelSelection(
          args.search_space, args, is_simulate=args.is_simulate
      )
      k_models, _, _, _ = rms.filtering_phase(
          N=n, K=k, train_loader=dataloader
      )
  
      # 3. Run refinement pahse
      data = {
          "u": 1,
          "k_models": k_models,
          "table_name": "dummy",
          "config_file": args.config_file,
      }
      response = requests.post(args.refinement_url, json=data).json()
      best_arch, best_arch_performance = (
          response["best_arch"],
          response["best_arch_performance"],
      )
      real_time_usage = time.time() - begin_time
  
      return orjson.dumps(
          {
              "best_arch": best_arch,
              "best_arch_performance": best_arch_performance,
              "time_usage": real_time_usage,
          }
      ).decode("utf-8")
  
imports: import calendar
  import os
  import time
  import requests
  import json
  from typing import List, Dict
  import traceback
  import orjson
  from argparse import Namespace
  from shared_config import parse_config_arguments
  from torch.utils.data import Dataset
  import torch
label_desc: Use image node_id 13 for calling a global function with example usage: model_selection_trails_workloads(params, args) and returns: orjson