code: def round_td_str(td: pd.Timedelta) -> str:
      """Round a timedelta to the nearest unit and convert to a string.
  
      Parameters
      ----------
      td : pd.Timedelta
          The timedelta to round.
  
      Returns
      -------
      str
          The rounded timedelta as a string.
          If the timedelta is == 0, None is returned.
  
      !!! info "See Also"
          [`timedelta_to_str`][figure_resampler.utils.timedelta_to_str]
  
      """
      for t_s in ("D", "H", "min", "s", "ms", "us", "ns"):
          if td > 0.95 * pd.Timedelta(f"1{t_s}"):
              return timedelta_to_str(td.round(t_s))
  
file_path: plotly-resampler/plotly_resampler/figure_resampler/utils.py
imports: import math
  import pandas
  from plotly.basedatatypes import BaseFigure
  from typing import Any
label_desc: Use image node_id 6 for calling a global function with example usage: round_td_str(td) and returns: timedelta_to_str