cimport numpy as cnp
from numpy cimport (
    ndarray,
)
from pandas._libs.tslibs.dtypes cimport (
    get_supported_reso,
)
from pandas._libs.tslibs.np_datetime cimport (
    convert_reso,
    get_datetime64_unit,
)
from pandas._libs.tslibs.np_datetime import (
    OutOfBoundsDatetime,
    OutOfBoundsTimedelta,
)
_no_input = object()
def ints_to_pytimedelta(ndarray m8values, box=False):
    def __new__(cls, object value=_no_input, unit=None, **kwargs):
            new_value = cnp.get_timedelta64_value(value)
            reso = get_datetime64_unit(value)
            new_reso = get_supported_reso(reso)
            if reso != NPY_DATETIMEUNIT.NPY_FR_GENERIC:
                try:
                    new_value = convert_reso(
                        new_value,
                        reso,
                        new_reso,
                        round_ok=True,
                    )
                except (OverflowError, OutOfBoundsDatetime) as err:
                    raise OutOfBoundsTimedelta(value) from err
