<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def mean(array, axis=None, skipna=None, **kwargs):
 """inhouse mean that can handle np.datetime64 or cftime.datetime dtypes"""

    from .common import _contains_cftime_datetimes

    array = asarray(array)
    if array.dtype.kind in 'Mm':
        offset = min(array)
        # xarray always uses np.datetime64[ns] for np.datetime64 data
        dtype = 'timedelta64[ns]'
        return _mean(datetime_to_numeric(array, offset), axis=axis,
                     skipna=skipna, **kwargs).astype(dtype) + offset
    elif _contains_cftime_datetimes(array):
        if isinstance(array, dask_array_type):
            raise NotImplementedError(
                'Computing the mean of an array containing '
                'cftime.datetime objects is not yet implemented on '
                'dask arrays.')
        offset = min(array)
        timedeltas = datetime_to_numeric(array, offset, datetime_unit='us')
        mean_timedeltas = _mean(timedeltas, axis=axis, skipna=skipna,
                                **kwargs)
        return _to_pytimedelta(mean_timedeltas, unit='us') + offset
    else:
        return _mean(array, axis=axis, skipna=skipna, **kwargs)