o
    i	                     @   sR   d dl Z e jdk rd dlmZ n	d dlm  mZ d dlZd dlm	Z	 dd Z
dS )    N2)index_tricks)internalc                 O   s  |j }t||}t||d}t|jdd }dd |D }zt|}W n t	y2   t
dw | || g|R i |}	t|	}	t|jdd |	j |	j}
|	|
|< |D ]}| || g|R i |}t||
|< qZt|	j D ]	}t|
d|}
qv|
S )a  Apply a function to 1-D slices along the given axis.

    Args:
        func1d (function (M,) -> (Nj...)): This function should accept 1-D
            arrays. It is applied to 1-D slices of ``arr`` along the specified
            axis. It must return a 1-D ``cupy.ndarray``.
        axis (integer): Axis along which ``arr`` is sliced.
        arr (cupy.ndarray (Ni..., M, Nk...)): Input array.
        args: Additional arguments for ``func1d``.
        kwargs: Additional keyword arguments for ``func1d``.

    Returns:
        cupy.ndarray: The output array. The shape of ``out`` is identical to
        the shape of ``arr``, except along the ``axis`` dimension. This
        axis is removed, and replaced with new dimensions equal to the
        shape of the return value of ``func1d``. So if ``func1d`` returns a
        scalar ``out`` will have one fewer dimensions than ``arr``.

    .. seealso:: :func:`numpy.apply_along_axis`
    Nc                 s   s    | ]}|t f V  qd S )N)Ellipsis).0ind r	   Q/home/ubuntu/veenaModal/venv/lib/python3.10/site-packages/cupy/lib/_shape_base.py	<genexpr>'   s    z#apply_along_axis.<locals>.<genexpr>z;Cannot apply_along_axis when any iteration dimensions are 0)ndimr   _normalize_axis_indexcupymoveaxisr   ndindexshapenextStopIteration
ValueErrorasarrayemptydtyperange)func1daxisarrargskwargsr   
inarr_viewindsind0resbuffr   outir	   r	   r
   apply_along_axis   s,   
r%   )numpy__version__	numpy.libr   numpy.lib._index_tricks_impllib_index_tricks_implr   
cupy._corer   r%   r	   r	   r	   r
   <module>   s    
