def apply_at(index: AxesLike, func: Callable, *args, **kwargs):
    '\n    Returns a function that takes an iterable and applies ``func`` to the values at the corresponding ``index``.\n\n    ``args`` and ``kwargs`` are passed to ``func`` as additional arguments.\n\n    Examples\n    --------\n    >>> first_sqr = apply_at(0, np.square)\n    >>> first_sqr([3, 2, 1])\n    >>> (9, 2, 1)\n    '
    index = set(np.atleast_1d(index).tolist())

    def wrapped(xs: Sequence, *args_, **kwargs_) -> tuple:
        index_ = {((i + len(xs)) if (i < 0) else i) for i in index}
        for idx in index_:
            if ((idx < 0) or (idx >= len(xs))):
                raise IndexError(f'Index {idx} out of bounds.')
        return tuple(((func(x, *args_, *args, **kwargs_, **kwargs) if (i in index_) else x) for (i, x) in enumerate(xs)))
    return wrapped
Returns a function that takes an iterable and applies ``func`` to the values at the corresponding ``index``.

``args`` and ``kwargs`` are passed to ``func`` as additional arguments.

Examples
--------
>>> first_sqr = apply_at(0, np.square)
>>> first_sqr([3, 2, 1])
>>> (9, 2, 1)
def apply_at(index: AxesLike, func: Callable, *args, **kwargs):
    '\n    Returns a function that takes an iterable and applies ``func`` to the values at the corresponding ``index``.\n\n    ``args`` and ``kwargs`` are passed to ``func`` as additional arguments.\n\n    Examples\n    --------\n    >>> first_sqr = apply_at(0, np.square)\n    >>> first_sqr([3, 2, 1])\n    >>> (9, 2, 1)\n    '
    index = set(np.atleast_1d(index).tolist())

    def wrapped(xs: Sequence, *args_, **kwargs_) -> tuple:
        index_ = {((i + len(xs)) if (i < 0) else i) for i in index}
        for idx in index_:
            if ((idx < 0) or (idx >= len(xs))):
                raise IndexError(f'Index {idx} out of bounds.')
        return tuple(((func(x, *args_, *args, **kwargs_, **kwargs) if (i in index_) else x) for (i, x) in enumerate(xs)))
    return wrapped