code: def run_client_gen(client, kwargs, do_md_to_text=True):
      res_dict = kwargs
      res_dict["prompt"] = (
          kwargs["instruction"] or kwargs["instruction_nochat"]
      )
      if not kwargs["stream_output"]:
          res = client.predict(
              str(dict(kwargs)), api_name="/submit_nochat_api"
          )
          res_dict1 = ast.literal_eval(res)
          res_dict.update(res_dict1)
          print(
              md_to_text(
                  res_dict["response"], do_md_to_text=do_md_to_text
              )
          )
          return res_dict, client
      else:
          job = client.submit(
              str(dict(kwargs)), api_name="/submit_nochat_api"
          )
          while not job.done():
              outputs_list = job.communicator.job.outputs
              if outputs_list:
                  res = job.communicator.job.outputs[-1]
                  res_dict1 = ast.literal_eval(res)
                  print("Stream: %s" % res_dict1["response"])
              time.sleep(0.1)
          res_list = job.outputs()
          assert len(res_list) > 0, "No response, check server"
          res = res_list[-1]
          res_dict1 = ast.literal_eval(res)
          print("Final: %s" % res_dict1["response"])
          res_dict.update(res_dict1)
          return res_dict, client
  
imports: import ast
  import time
  import os
  import markdown
  import pytest
  from bs4 import BeautifulSoup
  from src.utils import is_gradio_version4
  from tests.utils import get_inf_server
label_desc: Use image node_id 18 for calling a global function with example usage: run_client_gen(client, kwargs, do_md_to_text) and returns: res_dict,  client, res_dict,  client