code: def _format_stage_info(bar_width, stage_info, duration, timedelta_formatter=_pretty_time_delta):
      
      dur = timedelta_formatter(duration)
      percent = (stage_info.numCompletedTasks * bar_width) // stage_info.numTasks
      bar = [' '] * bar_width
      for i in range(bar_width):
          char = ' '
          if i < percent:
              char = '='
          if i == percent:
              char = '>'
          bar[i] = char
      bar = ''.join(bar)
      return "[Stage {info.stageId}:{bar} " \
             "({info.numCompletedTasks} + {info.numActiveTasks} / {info.numTasks} Dur: {dur}]" \
          .format(info=stage_info, dur=dur, bar=bar)
docs: Formats the Spark stage progress.
  
      Parameters
      ----------
      bar_width : int
          Width of the progressbar to print out.
      stage_info : :class:`pyspark.status.StageInfo`
          Information about the running stage
      stage_id : int
          Unique ID of the stage
      duration : :class:`datetime.timedelta`
          Duration of the stage so far
      timedelta_formatter : callable
          Converts a timedelta to a string.
  
      Returns
      -------
      formatted : str