code: def ttl_to_seconds(
      ttl: float | timedelta | str | None,
      *,
      coerce_none_to_inf: bool = True,
  ) -> float | None:
      """
      Convert a ttl value to a float representing "number of seconds".
      """
      if coerce_none_to_inf and ttl is None:
          return math.inf
      if isinstance(ttl, timedelta):
          return ttl.total_seconds()
      if isinstance(ttl, str):
          import numpy as np
          import pandas as pd
  
          try:
              out: float = pd.Timedelta(ttl).total_seconds()
          except ValueError as ex:
              raise BadTTLStringError(ttl) from ex
  
          if np.isnan(out):
              raise BadTTLStringError(ttl)
  
          return out
  
      return ttl
  
imports: from __future__ import annotations
  import functools
  import hashlib
  import inspect
  import math
  import threading
  import time
  import types
  from abc import abstractmethod
  from collections import defaultdict
  from datetime import timedelta
  from typing import Any, Callable, overload
  from typing_extensions import Literal
  from streamlit import type_util
  from streamlit.elements.spinner import spinner
  from streamlit.logger import get_logger
  from streamlit.runtime.caching.cache_errors import BadTTLStringError, CacheError, CacheKeyNotFoundError, UnevaluatedDataFrameError, UnhashableParamError, UnhashableTypeError, UnserializableReturnValueError, get_cached_func_name_md
  from streamlit.runtime.caching.cache_type import CacheType
  from streamlit.runtime.caching.cached_message_replay import CachedMessageReplayContext, CachedResult, MsgData, replay_cached_messages
  from streamlit.runtime.caching.hashing import HashFuncsDict, update_hash
  from streamlit.util import HASHLIB_KWARGS
label_desc: Use image node_id 3 for calling a global function with example usage: ttl_to_seconds(ttl) and returns: ttl, math, ttl, out