code: def to_timedelta(
      arg,
      unit: Optional[str] = None,
      errors: str = "raise",
  ):
      """
      Convert argument to timedelta.
  
      Parameters
      ----------
      arg : str, timedelta, list-like or Series
          The data to be converted to timedelta.
      unit : str, optional
          Denotes the unit of the arg for numeric `arg`. Defaults to ``"ns"``.
  
          Possible values:
          * 'W'
          * 'D' / 'days' / 'day'
          * 'hours' / 'hour' / 'hr' / 'h'
          * 'm' / 'minute' / 'min' / 'minutes' / 'T'
          * 'S' / 'seconds' / 'sec' / 'second'
          * 'ms' / 'milliseconds' / 'millisecond' / 'milli' / 'millis' / 'L'
          * 'us' / 'microseconds' / 'microsecond' / 'micro' / 'micros' / 'U'
          * 'ns' / 'nanoseconds' / 'nano' / 'nanos' / 'nanosecond' / 'N'
  
          Must not be specified when `arg` context strings and ``errors="raise"``.
  
          .. deprecated:: 4.0.0
              Units 'T' and 'L' are deprecated and will be removed in a future version.
  
      errors : {'ignore', 'raise', 'coerce'}, default 'raise'
          - If 'raise', then invalid parsing will raise an exception.
          - If 'coerce', then invalid parsing will be set as NaT.
          - If 'ignore', then invalid parsing will return the input.
  
      Returns
      -------
      ret : timedelta64, TimedeltaIndex or Series of timedelta64 if parsing succeeded.
  
      See Also
      --------
      DataFrame.astype : Cast argument to a specified dtype.
      to_datetime : Convert argument to datetime.
  
      Notes
      -----
      If the precision is higher than nanoseconds, the precision of the duration is
      truncated to nanoseconds for string inputs.
  
      Examples
      --------
      Parsing a single string to a Timedelta:
  
      >>> ps.to_timedelta('1 days 06:05:01.00003')
      Timedelta('1 days 06:05:01.000030')
      >>> ps.to_timedelta('15.5us')  # doctest: +SKIP
      Timedelta('0 days 00:00:00.000015500')
  
      Parsing a list or array of strings:
  
      >>> ps.to_timedelta(['1 days 06:05:01.00003', '15.5us', 'nan'])  # doctest: +SKIP
      TimedeltaIndex(['1 days 06:05:01.000030', '0 days 00:00:00.000015500', NaT],
                     dtype='timedelta64[ns]', freq=None)
  
      Converting numbers by specifying the `unit` keyword argument:
  
      >>> ps.to_timedelta(np.arange(5), unit='s')  # doctest: +SKIP
      TimedeltaIndex(['0 days 00:00:00', '0 days 00:00:01', '0 days 00:00:02',
                      '0 days 00:00:03', '0 days 00:00:04'],
                     dtype='timedelta64[ns]', freq=None)
      >>> ps.to_timedelta(np.arange(5), unit='d')  # doctest: +NORMALIZE_WHITESPACE
      TimedeltaIndex(['0 days', '1 days', '2 days', '3 days', '4 days'],
                     dtype='timedelta64[ns]', freq=None)
      """
  
      def pandas_to_timedelta(pser: pd.Series) -> np.timedelta64:
          return pd.to_timedelta(
              arg=pser,
              unit=unit,
              errors=errors,
          )
  
      if isinstance(arg, Series):
          return arg.transform(pandas_to_timedelta)
  
      else:
          return pd.to_timedelta(
              arg=arg,
              unit=unit,
              errors=errors,
          )
  
imports: from typing import Any, Callable, Dict, List, Optional, Set, Sized, Tuple, Type, Union, cast, no_type_check
  from collections.abc import Iterable
  from datetime import tzinfo
  from functools import reduce
  from io import BytesIO
  import json
  import warnings
  import numpy
  import pandas
  from pandas.api.types import is_datetime64_dtype, is_list_like
  from pandas.tseries.offsets import DateOffset
  import pyarrow
  import pyarrow.parquet
  from pyspark.sql import functions, Column
  from pyspark.sql.functions import pandas_udf
  from pyspark.sql.types import ByteType, ShortType, IntegerType, LongType, FloatType, DoubleType, BooleanType, TimestampType, TimestampNTZType, DecimalType, StringType, DateType, StructType, DataType
  from pyspark.sql.dataframe import DataFrame
  from pyspark import pandas
  from pyspark.pandas._typing import Axis, Dtype, Label, Name
  from pyspark.pandas.base import IndexOpsMixin
  from pyspark.pandas.utils import align_diff_frames, default_session, is_name_like_tuple, is_name_like_value, name_like_string, same_anchor, scol_for, validate_axis, log_advice
  from pyspark.pandas.frame import DataFrame, _reduce_spark_multi
  from pyspark.pandas.internal import InternalFrame, DEFAULT_SERIES_NAME, HIDDEN_COLUMNS, SPARK_INDEX_NAME_FORMAT
  from pyspark.pandas.series import Series, first_series
  from pyspark.pandas.spark.utils import as_nullable_spark_type, force_decimal_precision_scale
  from pyspark.pandas.indexes import Index, DatetimeIndex, TimedeltaIndex
  from pyspark.pandas.indexes.multi import MultiIndex
  from pyspark.sql.utils import get_column_class
label_desc: Use image node_id 17 for calling a global function with example usage: to_timedelta(arg, unit, errors) and returns: pd, arg, pd