code: def fmt_timespan_timedelta(
      delta: Any,
      detailed: bool = False,
      max_units: int = 3,
      precision: int = 10,
  ) -> str:
      if isinstance(delta, pd.Timedelta):
          num_seconds = delta.total_seconds()
          if delta.microseconds > 0:
              num_seconds += delta.microseconds * 1e-6
          if delta.nanoseconds > 0:
              num_seconds += delta.nanoseconds * 1e-9
          return fmt_timespan(num_seconds, detailed, max_units)
      else:
          return fmt_numeric(delta, precision)
  
imports: import decimal
  import math
  import re
  from datetime import timedelta
  from typing import Any, Callable, Dict, List, Optional, Union
  import numpy
  import pandas
  from markupsafe import escape
label_desc: Use image node_id 7 for calling a global function with example usage: fmt_timespan_timedelta(delta, detailed, max_units, precision) and returns: fmt_timespan, fmt_numeric