code: def validate_model(
      abi,
      device,
      model_file_path,
      weight_file_path,
      docker_image_tag,
      dockerfile_path,
      platform,
      device_type,
      input_nodes,
      output_nodes,
      input_shapes,
      output_shapes,
      input_data_formats,
      output_data_formats,
      model_output_dir,
      input_data_types,
      output_data_types,
      caffe_env,
      input_file_name="model_input",
      output_file_name="model_out",
      validation_threshold=0.9,
      backend="tensorflow",
      validation_outputs_data=[],
      log_file="",
  ):
      if not validation_outputs_data:
          six.print_("* Validate with %s" % platform)
      else:
          six.print_(
              "* Validate with file: %s" % validation_outputs_data
          )
      if abi != "host":
          for output_name in output_nodes:
              formatted_name = common.formatted_file_name(
                  output_file_name, output_name
              )
              if os.path.exists(
                  "%s/%s" % (model_output_dir, formatted_name)
              ):
                  sh.rm(
                      "-rf",
                      "%s/%s" % (model_output_dir, formatted_name),
                  )
              device.pull_from_data_dir(
                  formatted_name, model_output_dir
              )
  
      if platform in ["tensorflow", "onnx", "pytorch", "keras"]:
          validate(
              platform,
              model_file_path,
              "",
              "%s/%s" % (model_output_dir, input_file_name),
              "%s/%s" % (model_output_dir, output_file_name),
              device_type,
              ":".join(input_shapes),
              ":".join(output_shapes),
              ",".join(input_data_formats),
              ",".join(output_data_formats),
              ",".join(input_nodes),
              ",".join(output_nodes),
              validation_threshold,
              ",".join(input_data_types),
              ",".join(output_data_types),
              backend,
              validation_outputs_data,
              log_file,
          )
      elif platform == "caffe":
          image_name = "mace-caffe:" + docker_image_tag
          container_name = (
              "mace_caffe_" + docker_image_tag + "_validator"
          )
  
          if caffe_env == common.CaffeEnvType.LOCAL:
              try:
                  import caffe
              except ImportError:
                  logging.error("There is no caffe python module.")
              validate(
                  platform,
                  model_file_path,
                  weight_file_path,
                  "%s/%s" % (model_output_dir, input_file_name),
                  "%s/%s" % (model_output_dir, output_file_name),
                  device_type,
                  ":".join(input_shapes),
                  ":".join(output_shapes),
                  ",".join(input_data_formats),
                  ",".join(output_data_formats),
                  ",".join(input_nodes),
                  ",".join(output_nodes),
                  validation_threshold,
                  ",".join(input_data_types),
                  backend,
                  validation_outputs_data,
                  log_file,
              )
          elif caffe_env == common.CaffeEnvType.DOCKER:
              docker_image_id = sh.docker("images", "-q", image_name)
              if not docker_image_id:
                  six.print_("Build caffe docker")
                  sh.docker("build", "-t", image_name, dockerfile_path)
  
              container_id = sh.docker(
                  "ps", "-qa", "-f", "name=%s" % container_name
              )
              if container_id and not sh.docker(
                  "ps",
                  "-qa",
                  "--filter",
                  "status=running",
                  "-f",
                  "name=%s" % container_name,
              ):
                  sh.docker("rm", "-f", container_name)
                  container_id = ""
              if not container_id:
                  six.print_("Run caffe container")
                  sh.docker(
                      "run",
                      "-d",
                      "-it",
                      "--name",
                      container_name,
                      image_name,
                      "/bin/bash",
                  )
  
              for input_name in input_nodes:
                  formatted_input_name = common.formatted_file_name(
                      input_file_name, input_name
                  )
                  sh.docker(
                      "cp",
                      "%s/%s"
                      % (model_output_dir, formatted_input_name),
                      "%s:/mace" % container_name,
                  )
  
              for output_name in output_nodes:
                  formatted_output_name = common.formatted_file_name(
                      output_file_name, output_name
                  )
                  sh.docker(
                      "cp",
                      "%s/%s"
                      % (model_output_dir, formatted_output_name),
                      "%s:/mace" % container_name,
                  )
              model_file_name = os.path.basename(model_file_path)
              weight_file_name = os.path.basename(weight_file_path)
              sh.docker(
                  "cp", "tools/common.py", "%s:/mace" % container_name
              )
              sh.docker(
                  "cp", "tools/validate.py", "%s:/mace" % container_name
              )
              sh.docker(
                  "cp", model_file_path, "%s:/mace" % container_name
              )
              sh.docker(
                  "cp", weight_file_path, "%s:/mace" % container_name
              )
  
              sh.docker(
                  "exec",
                  container_name,
                  "python",
                  "-u",
                  "/mace/validate.py",
                  "--platform=caffe",
                  "--model_file=/mace/%s" % model_file_name,
                  "--weight_file=/mace/%s" % weight_file_name,
                  "--input_file=/mace/%s" % input_file_name,
                  "--mace_out_file=/mace/%s" % output_file_name,
                  "--device_type=%s" % device_type,
                  "--input_node=%s" % ",".join(input_nodes),
                  "--output_node=%s" % ",".join(output_nodes),
                  "--input_shape=%s" % ":".join(input_shapes),
                  "--output_shape=%s" % ":".join(output_shapes),
                  "--input_data_format=%s"
                  % ",".join(input_data_formats),
                  "--output_data_format=%s"
                  % ",".join(output_data_formats),
                  "--validation_threshold=%f" % validation_threshold,
                  "--input_data_type=%s" % ",".join(input_data_types),
                  "--backend=%s" % backend,
                  "--validation_outputs_data=%s"
                  % ",".join(validation_outputs_data),
                  "--log_file=%s" % log_file,
                  _fg=True,
              )
      elif platform == "megengine":
          validate(
              platform,
              model_file_path,
              "",
              "%s/%s" % (model_output_dir, input_file_name),
              "%s/%s" % (model_output_dir, output_file_name),
              device_type,
              ":".join(input_shapes),
              ":".join(output_shapes),
              ",".join(input_data_formats),
              ",".join(output_data_formats),
              ",".join(input_nodes),
              ",".join(output_nodes),
              validation_threshold,
              ",".join(input_data_types),
              backend,
              validation_outputs_data,
              log_file,
          )
  
      six.print_("Validation done!\n")
  
imports: import glob
  import logging
  import numpy
  import zlib
  import os
  import random
  import re
  import sh
  import struct
  import sys
  import time
  import platform
  import six
  import common
  from common import abi_to_internal
label_desc: Use image node_id 34 for calling a global function with example usage: validate_model(abi, device, model_file_path, weight_file_path, docker_image_tag, dockerfile_path, platform, device_type, input_nodes, output_nodes, input_shapes, output_shapes, input_data_formats, output_data_formats, model_output_dir, input_data_types, output_data_types, caffe_env, input_file_name, output_file_name, validation_threshold, backend, validation_outputs_data, log_file) without return types