code: def benchmark():
      filename = sys.argv[1]
      img = Image.open(filename)
      data = np.array(img.getdata(), dtype=np.uint8)
  
      if len(data.shape) == 1:
          n_channels = 1
          reshape = (img.height, img.width)
      else:
          n_channels = min(data.shape[1], 3)
          data = data[:, :n_channels]
          reshape = (img.height, img.width, n_channels)
  
      data = data.reshape(reshape).astype(np.uint8)
  
      methods = [
          simplest_countless,
          quick_countless,
          quick_countless_xor,
          quickest_countless,
          stippled_countless,
          zero_corrected_countless,
          countless,
          downsample_with_averaging,
          downsample_with_max_pooling,
          ndzoom,
          striding,
          # countless_if,
          # counting,
      ]
  
      formats = {1: "L", 3: "RGB", 4: "RGBA"}
  
      if not os.path.exists("./results"):
          os.mkdir("./results")
  
      N = 500
      img_size = float(img.width * img.height) / 1024.0 / 1024.0
      print(
          "N = %d, %dx%d (%.2f MPx) %d chan, %s"
          % (N, img.width, img.height, img_size, n_channels, filename)
      )
      print("Algorithm\tMPx/sec\tMB/sec\tSec")
      for fn in methods:
          print(fn.__name__, end="")
          sys.stdout.flush()
  
          start = time.time()
          # tqdm is here to show you what's going on the first time you run it.
          # Feel free to remove it to get slightly more accurate timing results.
          for _ in tqdm(range(N), desc=fn.__name__, disable=True):
              result = fn(data)
          end = time.time()
          print("\r", end="")
  
          total_time = end - start
          mpx = N * img_size / total_time
          mbytes = N * img_size * n_channels / total_time
          # Output in tab separated format to enable copy-paste into excel/numbers
          print(
              "%s\t%.3f\t%.3f\t%.2f"
              % (fn.__name__, mpx, mbytes, total_time)
          )
          outimg = Image.fromarray(
              np.squeeze(result), formats[n_channels]
          )
          outimg.save("./results/{}.png".format(fn.__name__, "PNG"))
  
imports: from __future__ import print_function, division
  import six
  from six.moves import range
  from collections import defaultdict
  from functools import reduce
  import operator
  import io
  import os
  from PIL import Image
  import math
  import numpy
  import random
  import sys
  import time
  from tqdm import tqdm
  from scipy import ndimage
label_desc: Use image node_id 18 for calling a global function with example usage: benchmark() without return types