code: def format_percentage(done, total):
      """Format percentage from given fraction while avoiding superflous precision."""
      if done == total:
          return "100%"
      if done == 0:
          return "0%"
      precision = 0
      fraction = done / total
      fmt_precision = "{{:.{}%}}".format
      fmt = lambda fraction: fmt_precision(precision).format(fraction)
      while fmt(fraction) == "100%" or fmt(fraction) == "0%":
          precision += 1
      return fmt(fraction)
  
imports: import logging
  import platform
  import time
  import datetime
  import sys
  import os
  import json
  import threading
  from functools import partial
  import inspect
  import textwrap
label_desc: Use image node_id 4 for calling a global function with example usage: format_percentage(done, total) and returns: fmt, str, str