code: def main(payload, endpoint, processes, threads, samples, time_based):
      file_type = None
      if checkers.is_url(payload):
          if payload.lower().endswith(".json"):
              file_type = "json"
              payload_data = requests.get(payload).json()
          elif payload.lower().endswith(".jpg"):
              file_type = "jpg"
              payload_data = imageio.imread(payload)
      elif checkers.is_file(payload):
          if payload.lower().endswith(".json"):
              file_type = "json"
              with open(payload, "r") as f:
                  payload_data = json.load(f)
          elif payload.lower().endswith(".jpg"):
              file_type = "jpg"
              payload_data = cv2.imread(payload, cv2.IMREAD_COLOR)
      else:
          print(
              f"'{payload}' isn't an URL resource, nor is it a local file"
          )
          sys.exit(1)
  
      if file_type is None:
          print(
              f"'{payload}' doesn't point to a jpg image or to a json file"
          )
          sys.exit(1)
      if file_type == "jpg":
          data = image_to_jpeg_bytes(payload_data)
      if file_type == "json":
          data = json.dumps(payload_data)
  
      print("Starting the inference throughput test...")
      results = []
      start = time.time()
      with concurrent.futures.ProcessPoolExecutor(
          max_workers=processes
      ) as executor:
          results = executor_submitter(
              executor,
              processes,
              process_worker,
              threads,
              data,
              endpoint,
              samples,
              time_based,
          )
      end = time.time()
      elapsed = end - start
  
      total_requests = sum(results)
  
      print(
          f"A total of {total_requests} requests have been served in {elapsed} seconds"
      )
      print(
          f"Avg number of inferences/sec is {total_requests / elapsed}"
      )
      print(
          f"Avg time spent on an inference is {elapsed / total_requests} seconds"
      )
  
file_path: cortex/test/utils/throughput_test.py
imports: import os
  import sys
  import click
  import concurrent.futures
  import requests
  import imageio
  import json
  import time
  import itertools
  import cv2
  import numpy
  from validator_collection import checkers
label_desc: Use image node_id 1 for calling a global function with example usage: main(payload, endpoint, processes, threads, samples, time_based) without return types