code: def get_interm_res_by_eid(eid, label):
      with sql.connect(
          app.app.config["db_file"], check_same_thread=False
      ) as con:
          cur = con.cursor()
          res = query_db(
              cur,
              "SELECT * from experiment WHERE \
                               JSON_EXTRACT(exp_config, '$.resource_args.track_intermediate_results') = 1 AND eid={eid}".format(
                  eid=eid
              ),
          )
  
          if len(res) == 0:
              return jsonify(dict())
  
          exp = res[0]
          name = str(exp["name"])
          script_name = str(json.loads(exp["exp_config"])["script"])
  
          obj = dict()
  
          list_mult_res_labels = None
          label_order = None
  
          mult_res_labels = query_db(
              cur,
              "SELECT JSON_EXTRACT(exp_config, '$.resource_args.multi_res_labels') AS labels \
                                      FROM experiment WHERE eid=?",
              (eid,),
          )
          mult_res_labels = mult_res_labels[0]
  
          if (
              mult_res_labels is not None
              and mult_res_labels["labels"] is not None
          ):
              list_mult_res_labels = json.loads(
                  mult_res_labels["labels"]
              )
              if label is not None:
                  label_order = list_mult_res_labels.index(label) + 1
              obj["multResLabels"] = list_mult_res_labels
  
          obj["eid"] = eid
          obj["name"] = name
          obj["scriptName"] = script_name
          obj["jobs"] = list()
  
          jids = query_db(
              cur,
              "SELECT jid from job WHERE \
                          eid={eid}".format(
                  eid=eid
              ),
          )
          for jid in jids:
              field = dict()
  
              jid_int = int(jid["jid"])
  
              field["jid"] = jid_int
              field["interimResults"] = list()
  
              interm_res = None
  
              if label is None:
                  interm_res = query_db(
                      cur,
                      "SELECT * from intermediate_result WHERE \
                                  jid={jid} ORDER BY receive_time".format(
                          jid=jid_int
                      ),
                  )
              elif (
                  list_mult_res_labels is not None
                  and label_order is not None
              ):
                  interm_res = query_db(
                      cur,
                      "SELECT *, value as score FROM multiple_result WHERE\
                                          jid={jid} and label_order={label_order} ORDER BY receive_time".format(
                          jid=jid_int, label_order=label_order
                      ),
                  )
  
              for in_res in interm_res:
                  field["interimResults"].append(
                      {
                          "irid": in_res["irid"],
                          "receiveTime": in_res["receive_time"],
                          "score": in_res["score"],
                      }
                  )
  
              obj["jobs"].append(field)
  
          return jsonify(obj)
  
imports: from flask import render_template, jsonify, request
  from flask_cors import CORS
  import connexion
  import click
  import logging
  import sys
  import sqlite3
  import os
  import os.path
  from six.moves.configparser import ConfigParser
  import json
  import signal
  import multiprocessing
  from aup.compression.utils import SERIALIZATION_SEPARATOR, run_non_automatic_experiment, verify_compression_config, adjust_compression_config
  from aup.setup import setup
  from aup.utils import get_default_username, set_default_keyvalue
  from ..ET.Connector.SQLiteConnector import SQLiteConnector
  from ..EE.Experiment import Experiment
  from ..aup import BasicConfig
  from aup.Proposer import get_proposer
  from threading import Lock
label_desc: Use image node_id 29 for calling a global function with example usage: get_interm_res_by_eid(eid, label) and returns: jsonify, jsonify