code: def run_model_with_conf(flags, args, model_name, model_conf):
      target_abi = "host"
      dev = device.HostDevice("host", target_abi)
      install_dir = "/tmp/micro_run/" + model_name
  
      if ModelKeys.check_tensors in model_conf:
          model_conf[ModelKeys.output_tensors] = model_conf[
              ModelKeys.check_tensors
          ]
          model_conf[ModelKeys.output_shapes] = model_conf[
              ModelKeys.check_shapes
          ]
  
      model_args = {
          "model_name": model_name,
          "input_node": ",".join(model_conf[ModelKeys.input_tensors]),
          "input_shape": join_2d_array(
              model_conf[ModelKeys.input_shapes]
          ),
          "output_node": ",".join(model_conf[ModelKeys.output_tensors]),
          "output_shape": join_2d_array(
              model_conf[ModelKeys.output_shapes]
          ),
          "input_data_format": ",".join(
              [
                  df.name
                  for df in model_conf[ModelKeys.input_data_formats]
              ]
          ),
          "output_data_format": ",".join(
              [
                  df.name
                  for df in model_conf[ModelKeys.output_data_formats]
              ]
          ),
      }
  
      opts = [
          "--%s=%s" % (arg_key, arg_val)
          for arg_key, arg_val in model_args.items()
      ] + args
  
      # generate data start
      tmp_dir_name = tempfile.mkdtemp()
      input_file_prefix = tmp_dir_name + "/" + model_name
      if ModelKeys.validation_inputs_data in model_conf:
          input_tensor = model_conf[ModelKeys.input_tensors]
          input_data = model_conf[ModelKeys.validation_inputs_data]
          mace_check(
              len(input_tensor) == len(input_data),
              "len(input_tensor) != len(validate_data",
          )
  
          for i in range(len(input_tensor)):
              util.download_or_get_file(
                  model_conf[ModelKeys.validation_inputs_data][i],
                  "",
                  util.formatted_file_name(
                      input_file_prefix, input_tensor[i]
                  ),
              )
      else:
          generate_input_data(
              input_file_prefix,
              model_conf[ModelKeys.input_tensors],
              model_conf[ModelKeys.input_shapes],
              model_conf[ModelKeys.input_ranges],
              model_conf[ModelKeys.input_data_types],
          )
  
      dev.install(Target(tmp_dir_name), install_dir + "/validate_in")
      target_input_file = "%s/validate_in/%s" % (
          install_dir,
          model_name,
      )
      target_output_dir = "%s/validate_out" % install_dir
      dev.mkdir(target_output_dir)
      target_output_file = target_output_dir + "/" + model_name
      opts += [
          "--input_file=%s" % target_input_file,
          "--output_file=%s" % target_output_file,
      ]
      # generate data end
  
      envs = []
      if flags.vlog_level > 0:
          envs += ["MACE_CPP_MIN_VLOG_LEVEL=%s" % flags.vlog_level]
  
      target = Target(
          "build/micro/host/tools/micro_run_static",
          [],
          opts=opts,
          envs=envs,
      )
      run_target.run_target(target_abi, install_dir, target, dev)
  
      if flags.validate:
          validate_model_file = util.download_or_get_model(
              model_conf[ModelKeys.model_file_path],
              model_conf[ModelKeys.model_sha256_checksum],
              tmp_dir_name,
          )
  
          validate_weight_file = ""
          if ModelKeys.weight_file_path in model_conf:
              validate_weight_file = util.download_or_get_model(
                  model_conf[ModelKeys.weight_file_path],
                  model_conf[ModelKeys.weight_sha256_checksum],
                  tmp_dir_name,
              )
  
          dev.pull(
              Target(target_output_dir), tmp_dir_name + "/validate_out"
          )
          output_file_prefix = (
              tmp_dir_name + "/validate_out/" + model_name
          )
          validate.validate(
              model_conf[ModelKeys.platform],
              validate_model_file,
              validate_weight_file,
              input_file_prefix,
              output_file_prefix,
              model_conf[ModelKeys.input_shapes],
              model_conf[ModelKeys.output_shapes],
              model_conf[ModelKeys.input_data_formats],
              model_conf[ModelKeys.output_data_formats],
              model_conf[ModelKeys.input_tensors],
              model_conf[ModelKeys.output_tensors],
              flags.validate_threshold,
              model_conf[ModelKeys.input_data_types],
              flags.backend,
              "",
              "",
          )
      shutil.rmtree(tmp_dir_name)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import argparse
  import copy
  import numpy
  import shutil
  import tempfile
  from micro_converter import MicroConverter
  from py_proto import mace_pb2
  import run_target
  from utils import util
  from utils import device
  from utils import config_parser
  from utils.target import Target
  from utils.config_parser import ModelKeys
  from utils.util import MaceLogger
  from utils.util import mace_check
  import validate
  import layers_validate
label_desc: Use image node_id 7 for calling a global function with example usage: run_model_with_conf(flags, args, model_name, model_conf) without return types