code: def _coerce_scalar_to_timedelta_type(
      r, unit="ns", box=True, errors="raise"
  ):
      """Convert string 'r' to a timedelta object."""
  
      try:
          result = Timedelta(r, unit)
          if not box:
              # explicitly view as timedelta64 for case when result is pd.NaT
              result = result.asm8.view("timedelta64[ns]")
      except ValueError:
          if errors == "raise":
              raise
          elif errors == "ignore":
              return r
  
          # coerce
          result = pd.NaT
  
      return result
  
file_path: catboost/contrib/python/pandas/py2/pandas/core/tools/timedeltas.py
imports: import numpy
  from pandas._libs.tslibs.timedeltas import Timedelta, parse_timedelta_unit
  from pandas.core.dtypes.common import is_list_like
  from pandas.core.dtypes.generic import ABCIndexClass, ABCSeries
  import pandas
  from pandas.core.arrays.timedeltas import sequence_to_td64ns
label_desc: Use image node_id 2 for calling a global function with example usage: _coerce_scalar_to_timedelta_type(r, unit, box, errors) and returns: result, r