
    `i                         d dl Z d dlZd dlZej                            ej                  dk    Z G d de          Zd	dZ	d
dZ
d Zd ZdS )    Nz1.10.0c                   ,    e Zd Zd Zd Zd Zd Zd ZdS )NpzFilec                     || _         d S N)npz_file)selfr   s     `/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/cupy/_io/npz.py__init__zNpzFile.__init__   s         c                 8    | j                                          | S r   )r   	__enter__r   s    r	   r   zNpzFile.__enter__   s    !!!r   c                 >    | j                             |||           d S r   )r   __exit__)r   typval	tracebacks       r	   r   zNpzFile.__exit__   s"    sC33333r   c                 D    | j         |         }t          j        |          S r   )r   cupyarray)r   keyarrs      r	   __getitem__zNpzFile.__getitem__   s    mC z#r   c                 8    | j                                          d S r   )r   closer   s    r	   r   zNpzFile.close   s    r   N)__name__
__module____qualname__r
   r   r   r   r    r   r	   r   r      s_        ! ! !  4 4 4      r   r   c                 f   t           r|dn|}t          j        | ||          }n+|t          j        d           t          j        | |          }t          |t          j                  rt          j        |          S t          |t          j	        j
        j                  rt          |          S |S )a  Loads arrays or pickled objects from ``.npy``, ``.npz`` or pickled file.

    This function just calls ``numpy.load`` and then sends the arrays to the
    current device. NPZ file is converted to NpzFile object, which defers the
    transfer to the time of accessing the items.

    Args:
        file (file-like object or string): The file to read.
        mmap_mode (None, 'r+', 'r', 'w+', 'c'): If not ``None``, memory-map the
            file to construct an intermediate :class:`numpy.ndarray` object and
            transfer it to the current device.
        allow_pickle (bool): Allow loading pickled object arrays stored in npy
            files. Reasons for disallowing pickles include security, as
            loading pickled data can execute arbitrary code. If pickles are
            disallowed, loading object arrays will fail.
            Please be aware that CuPy does not support arrays with dtype of
            `object`.
            The default is False.
            This option is available only for NumPy 1.10 or later.
            In NumPy 1.9, this option cannot be specified (loading pickled
            objects is always allowed).

    Returns:
        CuPy array or NpzFile object depending on the type of the file. NpzFile
        object is a dictionary-like object with the context manager protocol
        (which enables us to use *with* statement on it).

    .. seealso:: :func:`numpy.load`

    NF1allow_pickle option is not supported in NumPy 1.9)_support_allow_picklenumpyloadwarningswarn
isinstancendarrayr   r   libnpyior   )file	mmap_modeallow_pickleobjs       r	   r$   r$      s    >  * , 4uu,jy,77#MMNNNjy))#u}%% z#	C0	1	1 s||
r   c                     t           r0|dn|}t          j        | t          j        |          |           dS |t          j        d           t          j        | t          j        |                     dS )a  Saves an array to a binary file in ``.npy`` format.

    Args:
        file (file or str): File or filename to save.
        arr (array_like): Array to save. It should be able to feed to
            :func:`cupy.asnumpy`.
        allow_pickle (bool): Allow saving object arrays using Python pickles.
            Reasons for disallowing pickles include security (loading pickled
            data can execute arbitrary code) and portability (pickled objects
            may not be loadable on different Python installations, for example
            if the stored objects require libraries that are not available,
            and not all pickled data is compatible between Python 2 and Python
            3).
            The default is True.
            This option is available only for NumPy 1.10 or later.
            In NumPy 1.9, this option cannot be specified (saving objects
            using pickles is always allowed).

    .. seealso:: :func:`numpy.save`

    NTr!   )r"   r#   saver   asnumpyr%   r&   )r+   r   r-   s      r	   r0   r0   N   sw    ,  ,+3tt
4c**L99999#MMNNN
4c**+++++r   c                     t          t          j        |          }|D ]}t          j        ||                   ||<    t          j        | g|R i | dS )aT  Saves one or more arrays into a file in uncompressed ``.npz`` format.

    Arguments without keys are treated as arguments with automatic keys named
    ``arr_0``, ``arr_1``, etc. corresponding to the positions in the argument
    list. The keys of arguments are used as keys in the ``.npz`` file, which
    are used for accessing NpzFile object when the file is read by
    :func:`cupy.load` function.

    Args:
        file (file or str): File or filename to save.
        *args: Arrays with implicit keys.
        **kwds: Arrays with explicit keys.

    .. seealso:: :func:`numpy.savez`

    N)mapr   r1   r#   savezr+   argskwdsr   s       r	   r4   r4   m   sc    " t|T""D , ,Lc++S			K$t$$$t$$$$$r   c                     t          t          j        |          }|D ]}t          j        ||                   ||<    t          j        | g|R i | dS )a  Saves one or more arrays into a file in compressed ``.npz`` format.

    It is equivalent to :func:`cupy.savez` function except the output file is
    compressed.

    .. seealso::
       :func:`cupy.savez` for more detail,
       :func:`numpy.savez_compressed`

    N)r3   r   r1   r#   savez_compressedr5   s       r	   r9   r9      sd     t|T""D , ,Lc++S			4/$///$/////r   )NNr   )r%   r#   r   r)   NumpyVersion__version__r"   objectr   r$   r0   r4   r9   r   r   r	   <module>r=      s       //0ABBhN     f   (, , , ,^, , , ,>% % %.0 0 0 0 0r   