code: def _pretty_time_delta(td):
      
      seconds = td.total_seconds()
      sign_string = '-' if seconds < 0 else ''
      seconds = abs(int(seconds))
      days, seconds = divmod(seconds, 86400)
      hours, seconds = divmod(seconds, 3600)
      minutes, seconds = divmod(seconds, 60)
      d = dict(sign=sign_string, days=days, hours=hours, minutes=minutes, seconds=seconds)
      if days > 0:
          return '{sign}{days}d{hours:02d}h{minutes:02d}m:{seconds:02d}s'.format(**d)
      elif hours > 0:
          return '{sign}{hours:02d}h{minutes:02d}m:{seconds:02d}s'.format(**d)
      elif minutes > 0:
          return '{sign}{minutes:02d}m:{seconds:02d}s'.format(**d)
      else:
          return '{sign}{seconds:02d}s'.format(**d)
docs: Creates a string representation of a time delta.
  
      Parameters
      ----------
      td : :class:`datetime.timedelta`
  
      Returns
      -------
      pretty_formatted_datetime : str