
    `i3                       d dl mZ d dlmZmZmZmZmZ erddlm	Z	m
Z
mZmZmZ d dlmZ ddlmZ d dlZd dlm
Z d d	lmZ d
 ZdddddCdZ	 	 dDddddEdZddddFd ZddddGd"Z	 dHd ddd#dId)ZdJd+ZddddKd-ZddddLd.Z ddd/d0dMd4Z!d5d6dNd;Z"ddddFd<Z#ddddGd=Z$d d>dOd?Z%d d>dOd@Z&ddddFdAZ'ddddGdBZ(dS )P    )annotations)TYPE_CHECKINGListOptionalTupleUnion   )ArrayDeviceDtypeNestedSequenceSupportsBufferProtocol)Sequence)_all_dtypesN)r   )runtimec                H    dt           z   D ]	}| |u r d S 
t          d          )NNz)dtype must be one of the supported dtypes)r   
ValueError)dtypeds     v/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/cupy/array_api/_creation_functions.py_check_valid_dtyper      s<    
 {"  A::FF 
@
A
AA    )r   devicecopyobjZUnion[Array, bool, int, float, NestedSequence[bool | int | float], SupportsBufferProtocol]r   Optional[Dtype]r   Optional[Device]r   Optional[bool]returnr
   c              ~   ddl m} t          |           |'t          |t                    st          d|          |t	                      }|du rt          d          t          | |          r|| j        |k    rd}|du rt          j	                    }	 t          j
        |j                    |j        t          j        | j        d|                    } t          j
        |           n# t          j
        |           w xY w| S |0t          | t                     r| d	k    s| d
k     rt#          d          t          j	                    }	 t          j
        |j                   t          j        | |          }t          j
        |           n# t          j
        |           w xY w |j        |          S )z~
    Array API compatible wrapper for :py:func:`np.asarray <numpy.asarray>`.

    See its docstring for more information.
    r	   r
   NUnsupported device Fz!copy=False is not yet implementedT)r   r   l            l         z&Integer out of bounds for array dtypesr   )_array_objectr
   r   
isinstance_Devicer   NotImplementedErrorr   r   	getDevice	setDeviceid_newnparray_arrayintOverflowErrorasarray)r   r   r   r   r
   prev_deviceress          r   r3   r3   !   s   , %$$$$$u*VW"="=9v99:::~u}}!"EFFF#u 
e!3!3D4<<!+--K/!&),,, ej#*4u!M!M!MNN!+....!+....
}C--}3==C*DTDT DEEE#%%K'&)$$$jE***+&&&&+&&&&5:c??s   AC1 1D/F F,)r   r   stopOptional[Union[int, float]]stepUnion[int, float]startc                 ddl m} t          |           |'t          |t                    st          d|          |t	                      }t          j                    }	 t          j        |j	                    |j
        t          j        | |||                    t          j        |           S # t          j        |           w xY w)z|
    Array API compatible wrapper for :py:func:`np.arange <numpy.arange>`.

    See its docstring for more information.
    r	   r#   Nr$   )r6   r8   r   )r&   r
   r   r'   r(   r   r   r*   r+   r,   r-   r.   arange)r:   r6   r8   r   r   r
   r4   s          r   r<   r<   Y   s     %$$$$$u*VW"="=9v99:::~#%%K'&)$$$uz")E4uMMMNN+&&&&+&&&&   #>B6 6CshapeUnion[int, Tuple[int, ...]]c                  ddl m} t          |           |'t          |t                    st          d|          |t	                      }t          j                    }	 t          j        |j	                    |j
        t          j        | |                    t          j        |           S # t          j        |           w xY w)zz
    Array API compatible wrapper for :py:func:`np.empty <numpy.empty>`.

    See its docstring for more information.
    r	   r#   Nr$   r%   )r&   r
   r   r'   r(   r   r   r*   r+   r,   r-   r.   emptyr>   r   r   r
   r4   s        r   rA   rA   v        %$$$$$u*VW"="=9v99:::~#%%K'&)$$$uz"(566677+&&&&+&&&&   #<B4 4C
xc                 ddl m} t          |           |'t          |t                    st          d|          |t	                      }t          j                    }	 t          j        |j	                    |j
        t          j        | j        |                    t          j        |           S # t          j        |           w xY w)z
    Array API compatible wrapper for :py:func:`np.empty_like <numpy.empty_like>`.

    See its docstring for more information.
    r	   r#   Nr$   r%   )r&   r
   r   r'   r(   r   r   r*   r+   r,   r-   r.   
empty_liker0   rE   r   r   r
   r4   s        r   rG   rG           %$$$$$u*VW"="=9v99:::~#%%K'&)$$$uz"->>>??+&&&&+&&&&   #AB9 9C)kr   r   n_rowsr1   n_colsOptional[int]rK   c                 ddl m} t          |           |'t          |t                    st          d|          |t	                      }t          j                    }	 t          j        |j	                    |j
        t          j        | |||                    t          j        |           S # t          j        |           w xY w)zv
    Array API compatible wrapper for :py:func:`np.eye <numpy.eye>`.

    See its docstring for more information.
    r	   r#   Nr$   )MrK   r   )r&   r
   r   r'   r(   r   r   r*   r+   r,   r-   r.   eye)rL   rM   rK   r   r   r
   r4   s          r   rQ   rQ      s     %$$$$$u*VW"="=9v99:::~#%%K'&)$$$uz"&6QeDDDEE+&&&&+&&&&r=   objectc               R    ddl m}  |j        t          j        |                     S )z
    Array API compatible wrapper for :py:func:`np.from_dlpack <numpy.from_dlpack>`.

    See its docstring for more information.
    r	   r#   )r&   r
   r-   r.   from_dlpack)rE   r
   s     r   rT   rT      s2     %$$$$$5:bnQ''(((r   
fill_valuec                   ddl m} t          |           |'t          |t                    st          d|          |t	                      }t          ||          r|j        dk    r|j        }t          j	                    }	 t          j
        |j                   t          j        | ||          }t          j
        |           n# t          j
        |           w xY w|j        t          vrt!          d           |j        |          S )zx
    Array API compatible wrapper for :py:func:`np.full <numpy.full>`.

    See its docstring for more information.
    r	   r#   Nr$   r   r%   zInvalid input to full)r&   r
   r   r'   r(   r   ndimr0   r   r*   r+   r,   r.   fullr   r   	TypeErrorr-   )r>   rU   r   r   r
   r4   r5   s          r   rX   rX      s    %$$$$$u*VW"="=9v99:::~*e$$ 'A)=)=&
#%%K'&)$$$geZu555+&&&&+&&&&
y## /0005:c??s   0C
 
C c              *   ddl m} t          |           |'t          |t                    st          d|          |t	                      }t          ||          r|j        dk    r|j        }t          j	                    }	 t          j
        |j                   t          j        | j        ||          }t          j
        |           n# t          j
        |           w xY w|j        t          vrt!          d           |j        |          S )z
    Array API compatible wrapper for :py:func:`np.full_like <numpy.full_like>`.

    See its docstring for more information.
    r	   r#   Nr$   r   r%   zInvalid input to full_like)r&   r
   r   r'   r(   r   rW   r0   r   r*   r+   r,   r.   	full_liker   r   rY   r-   )rE   rU   r   r   r
   r4   r5   s          r   r[   r[      s    %$$$$$u*VW"="=9v99:::~*e$$ 'A)=)=&
#%%K'&)$$$l18Zu===+&&&&+&&&&
y## 45555:c??s   5C C%T)r   r   endpointnumr\   boolc         	        ddl m} t          |           |t                      }n't	          |t                    st          d|          t          j                    }	 t          j        |j	                    |j
        t          j        | ||||                    t          j        |           S # t          j        |           w xY w)z
    Array API compatible wrapper for :py:func:`np.linspace <numpy.linspace>`.

    See its docstring for more information.
    r	   r#   Nr$   )r   r\   )r&   r
   r   r(   r'   r   r   r*   r+   r,   r-   r.   linspace)r:   r6   r]   r   r   r\   r
   r4   s           r   r`   r`     s     %$$$$$u~(( ;9v99:::#%%K'&)$$$uz"+eT3ehWWWXX+&&&&+&&&&s   "?B6 6Cxy)indexingarraysrb   strList[Array]c                    ddl m t          d |D                       dk    rt          d          fdt	          j        d |D             d| iD             S )z
    Array API compatible wrapper for :py:func:`np.meshgrid <numpy.meshgrid>`.

    See its docstring for more information.
    r	   r#   c                    h | ]	}|j         
S  r%   .0as     r   	<setcomp>zmeshgrid.<locals>.<setcomp><  s    $$$AG$$$r   z,meshgrid inputs must all have the same dtypec                0    g | ]} j         |          S rh   )r-   )rj   r/   r
   s     r   
<listcomp>zmeshgrid.<locals>.<listcomp>?  s5        	
5  r   c                    g | ]	}|j         
S rh   )r0   ri   s     r   rn   zmeshgrid.<locals>.<listcomp>A  s    "<"<"<18"<"<"<r   rb   )r&   r
   lenr   r.   meshgrid)rb   rc   r
   s     @r   rq   rq   1  s     %$$$$$
 $$V$$$%%))GHHH   ["<"<V"<"<"<PxPP   r   c                  ddl m} t          |           |'t          |t                    st          d|          |t	                      }t          j                    }	 t          j        |j	                    |j
        t          j        | |                    t          j        |           S # t          j        |           w xY w)zx
    Array API compatible wrapper for :py:func:`np.ones <numpy.ones>`.

    See its docstring for more information.
    r	   r#   Nr$   r%   )r&   r
   r   r'   r(   r   r   r*   r+   r,   r-   r.   onesrB   s        r   rs   rs   E  s     %$$$$$u*VW"="=9v99:::~#%%K'&)$$$uz"'%u55566+&&&&+&&&&rD   c                 ddl m} t          |           |'t          |t                    st          d|          |t	                      }t          j                    }	 t          j        |j	                    |j
        t          j        | j        |                    t          j        |           S # t          j        |           w xY w)z
    Array API compatible wrapper for :py:func:`np.ones_like <numpy.ones_like>`.

    See its docstring for more information.
    r	   r#   Nr$   r%   )r&   r
   r   r'   r(   r   r   r*   r+   r,   r-   r.   	ones_liker0   rH   s        r   ru   ru   _  s     %$$$$$u*VW"="=9v99:::~#%%K'&)$$$uz",qxu===>>+&&&&+&&&&rJ   rK   c                  ddl m} | j        dk     rt          d           |j        t          j        | j        |                    S )zx
    Array API compatible wrapper for :py:func:`np.tril <numpy.tril>`.

    See its docstring for more information.
    r	   r#      z)x must be at least 2-dimensional for trilrv   )r&   r
   rW   r   r-   r.   trilr0   rE   rK   r
   s      r   ry   ry   v  S     %$$$$$vzzDEEE5:bgah!,,,---r   c                  ddl m} | j        dk     rt          d           |j        t          j        | j        |                    S )zx
    Array API compatible wrapper for :py:func:`np.triu <numpy.triu>`.

    See its docstring for more information.
    r	   r#   rx   z)x must be at least 2-dimensional for triurv   )r&   r
   rW   r   r-   r.   triur0   rz   s      r   r}   r}     r{   r   c                  ddl m} t          |           |'t          |t                    st          d|          |t	                      }t          j                    }	 t          j        |j	                    |j
        t          j        | |                    t          j        |           S # t          j        |           w xY w)zz
    Array API compatible wrapper for :py:func:`np.zeros <numpy.zeros>`.

    See its docstring for more information.
    r	   r#   Nr$   r%   )r&   r
   r   r'   r(   r   r   r*   r+   r,   r-   r.   zerosrB   s        r   r   r     rC   rD   c                 ddl m} t          |           |'t          |t                    st          d|          |t	                      }t          j                    }	 t          j        |j	                    |j
        t          j        | j        |                    t          j        |           S # t          j        |           w xY w)z
    Array API compatible wrapper for :py:func:`np.zeros_like <numpy.zeros_like>`.

    See its docstring for more information.
    r	   r#   Nr$   r%   )r&   r
   r   r'   r(   r   r   r*   r+   r,   r-   r.   
zeros_liker0   rH   s        r   r   r     rI   rJ   )
r   r   r   r   r   r   r   r    r!   r
   )Nr	   )r6   r7   r8   r9   r:   r9   r   r   r   r   r!   r
   )r>   r?   r   r   r   r   r!   r
   )rE   r
   r   r   r   r   r!   r
   r   )rL   r1   rM   rN   rK   r1   r   r   r   r   r!   r
   )rE   rR   r!   r
   )
r>   r?   rU   r9   r   r   r   r   r!   r
   )
rU   r9   rE   r
   r   r   r   r   r!   r
   )r]   r1   r:   r9   r6   r9   r   r   r   r   r\   r^   r!   r
   )rc   r
   rb   rd   r!   re   )rE   r
   rK   r1   r!   r
   ))
__future__r   typingr   r   r   r   r   _typingr
   r   r   r   r   collections.abcr   _dtypesr   cupyr.   	cupy.cudar(   cupy_backends.cuda.apir   r   r3   r<   rA   rG   rQ   rT   rX   r[   r`   rq   rs   ru   ry   r}   r   r   rh   r   r   <module>r      si   " " " " " " ? > > > > > > > > > > > > > )              )(((((                 ' ' ' ' ' ' * * * * * *B B B, "#5 5 5 5 5 5v )-	' "#' ' ' ' ' '@ "#	' ' ' ' ' '6 .2d' ' ' ' ' '2 !'
 !#' ' ' ' ' ':) ) ) ) "#     N "#           R "#' ' ' ' ' '< .2      . "#	' ' ' ' ' '6 .2d' ' ' ' ' '. #$ . . . . . . #$ . . . . . ." "#	' ' ' ' ' '6 .2d' ' ' ' ' ' ' 'r   