code: def track_progress(
      func, tasks, bar_width=50, file=sys.stdout, **kwargs
  ):
      """Track the progress of tasks execution with a progress bar.
  
      Tasks are done with a simple for-loop.
  
      Args:
          func (callable): The function to be applied to each task.
          tasks (list or tuple[Iterable, int]): A list of tasks or
              (tasks, total num).
          bar_width (int): Width of progress bar.
  
      Returns:
          list: The task results.
      """
      if isinstance(tasks, tuple):
          assert len(tasks) == 2
          assert isinstance(tasks[0], Iterable)
          assert isinstance(tasks[1], int)
          task_num = tasks[1]
          tasks = tasks[0]
      elif isinstance(tasks, Iterable):
          task_num = len(tasks)
      else:
          raise TypeError(
              '"tasks" must be an iterable object or a (iterator, int) tuple'
          )
      prog_bar = ProgressBar(task_num, bar_width, file=file)
      results = []
      for task in tasks:
          results.append(func(task, **kwargs))
          prog_bar.update()
      prog_bar.file.write("\n")
      return results
  
file_path: lavis/lavis/common/annotator/uniformer/mmcv/utils/progressbar.py
imports: import sys
  from collections.abc import Iterable
  from multiprocessing import Pool
  from shutil import get_terminal_size
  from .timer import Timer
label_desc: Use image node_id 1 for calling a global function with example usage: track_progress(func, tasks, bar_width, file) and returns: results