code: def bench(image, thread_count):
      """Encode `image` to PNG on `thread_count` threads in parallel.
  
      Returns:
        A `float` representing number of seconds that it takes all threads
        to finish encoding `image`.
      """
      threads = [
          threading.Thread(target=lambda: encoder.encode_png(image))
          for _ in range(thread_count)
      ]
      start_time = datetime.datetime.now()
      for thread in threads:
          thread.start()
      for thread in threads:
          thread.join()
      end_time = datetime.datetime.now()
      delta = (end_time - start_time).total_seconds()
      return delta
  
file_path: tensorboard/tensorboard/encode_png_benchmark.py
imports: import datetime
  import threading
  import time
  from absl import app
  from absl import logging
  import numpy
  from tensorboard.util import encoder
  from tensorboard.util import tb_logging
label_desc: Use image node_id 1 for calling a global function with example usage: bench(image, thread_count) and returns: delta