code: def td_format(
      td_object: None | dt.timedelta | float | int,
  ) -> str | None:
      """
      Format a timedelta object or float/int into a readable string for time duration.
  
      For example timedelta(seconds=3752) would become `1h:2M:32s`.
      If the time is less than a second, the return will be `<1s`.
      """
      if not td_object:
          return None
      if isinstance(td_object, dt.timedelta):
          delta = relativedelta() + td_object
      else:
          delta = relativedelta(seconds=int(td_object))
      # relativedelta for timedelta cannot convert days to months
      # so calculate months by assuming 30 day months and normalize
      months, delta.days = divmod(delta.days, 30)
      delta = delta.normalized() + relativedelta(months=months)
  
      def _format_part(key: str) -> str:
          value = int(getattr(delta, key))
          if value < 1:
              return ""
          # distinguish between month/minute following strftime format
          # and take first char of each unit, i.e. years='y', days='d'
          if key == "minutes":
              key = key.upper()
          key = key[0]
          return f"{value}{key}"
  
      parts = map(
          _format_part,
          ("years", "months", "days", "hours", "minutes", "seconds"),
      )
      joined = ":".join(part for part in parts if part)
      if not joined:
          return "<1s"
      return joined
  
imports: from __future__ import annotations
  import datetime
  from typing import TYPE_CHECKING, overload
  import pendulum
  from dateutil.relativedelta import relativedelta
  from pendulum.datetime import DateTime
label_desc: Use image node_id 19 for calling a global function with example usage: td_format(td_object) and returns: joined, None, value, key, str, str