code: def run_modules(
      mod_configs,
      dev,
      target,
      global_input_name,
      global_input_data,
      mod_set_input,
      input_name,
      input_data,
      params_mod=None,
      params=None,
  ):
      # Running modules in serialized model. The returnning data are used to verify the pipeline
      # executor result.
      mod_input = {}
      final_output = {}
      idx = 0
      for mod in mod_configs:
          with tvm.transform.PassContext(opt_level=3):
              lib = relay.build(mod, target)
  
          m = graph_executor.GraphModule(lib["default"](dev))
          # Getting the input data then setting the input data into the module.
          if idx in mod_input:
              for input in mod_input[idx]:
                  input = mod_input[idx][input]
                  m.set_input(input["index"], input["data"])
          else:
              m.set_input(global_input_name, global_input_data)
  
          # Setting the "input_data" into the module.
          if mod == mod_set_input:
              m.set_input(input_name, input_data)
          # If the module is "params_mod" then setting the parameters to this module.
          if params_mod == mod:
              m.set_input(None, None, **params)
  
          m.run()
          n = m.get_num_outputs()
          # Setting current output data as  the input of next module.
          mconfig = mod_configs[mod]
          for output in mconfig["pipeline"]["output"]:
              output_data = m.get_output(output["output_idx"]).numpy()
              for dep in output["dependencies"]:
                  is_global = False
                  if "global_output_index" in dep:
                      is_global = True
                      name = dep["global_output_index"]
                  else:
                      mod_idx = dep["mod_idx"]
                      name = dep["input_name"]
                  if is_global:
                      final_output[name] = output_data
                  else:
                      if mod_idx in mod_input:
                          mod_input[mod_idx][name] = {
                              "index": name,
                              "data": output_data,
                          }
                      else:
                          mod_input[mod_idx] = {
                              name: {"index": name, "data": output_data}
                          }
          idx = idx + 1
  
      return final_output
  
imports: import pytest
  import os
  import time
  import numpy
  import tvm
  import tvm.testing
  from tvm import relay
  from tvm.relay import transform, build_module
  from tvm.relay.testing import run_opt_pass
  from tvm.contrib import graph_executor, pipeline_executor, pipeline_executor_build
  from tvm._ffi import get_global_func
  from tvm.contrib import cc
label_desc: Use image node_id 7 for calling a global function with example usage: run_modules(mod_configs, dev, target, global_input_name, global_input_data, mod_set_input, input_name, input_data, params_mod, params) and returns: final_output