o
    }o™iB  ã                   @   s‚   d dl mZ d dlmZ d dlmZ d dlmZmZm	Z	 ddgZ
G dd„ dejeeƒZG dd„ dejeeƒZeG d	d
„ d
ƒƒZdS )é    )Ú	dataclass)ÚOptional)Údata)ÚSerializationÚTypingÚ	typecheckÚDatasetÚIterableDatasetc                   @   ó&   e Zd ZdZdd„ Zeƒ dd„ ƒZdS )r   zrDataset with output ports

    Please Note: Subclasses of IterableDataset should *not* implement input_types.
    c                 C   ó   t j |¡S ©zŒ
        A default implementation of a collation function.
        Users should override this method to define custom data loaders.
        ©r   Ú
dataloaderÚdefault_collate©ÚselfÚbatch© r   úM/home/ubuntu/.local/lib/python3.10/site-packages/nemo/core/classes/dataset.pyÚ_collate_fn   ó   zDataset._collate_fnc                 C   ó   | j dur	tdƒ‚|  |¡S )a  
        This is the method that user pass as functor to DataLoader.
        The method optionally performs neural type checking and add types to the outputs.

        Please note, subclasses of Dataset should not implement `input_types`.

        Usage:

        .. code-block:: python

            dataloader = torch.utils.data.DataLoader(
                    ....,
                    collate_fn=dataset.collate_fn,
                    ....
            )

        Returns:
            Collated batch, with or without types.
        NúCDatasets should not implement `input_types` as they are not checked©Úinput_typesÚ	TypeErrorr   r   r   r   r   Ú
collate_fn%   s   

zDataset.collate_fnN©Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r      ó
    c                   @   r
   )r	   z{Iterable Dataset with output ports

    Please Note: Subclasses of IterableDataset should *not* implement input_types.
    c                 C   r   r   r   r   r   r   r   r   G   r   zIterableDataset._collate_fnc                 C   r   )a”  
        This is the method that user pass as functor to DataLoader.
        The method optionally performs neural type checking and add types to the outputs.

        # Usage:
        dataloader = torch.utils.data.DataLoader(
                ....,
                collate_fn=dataset.collate_fn,
                ....
        )

        Returns:
            Collated batch, with or without types.
        Nr   r   r   r   r   r   r   N   s   

zIterableDataset.collate_fnNr   r   r   r   r   r	   A   r"   c                   @   sN   e Zd ZU dZeed< dZeed< dZeed< dZ	e
e ed< dZeed	< d
S )ÚDatasetConfigé    Ú
batch_sizeFÚ	drop_lastÚshuffler   Únum_workersTÚ
pin_memoryN)r   r   r    r%   ÚintÚ__annotations__r&   Úboolr'   r(   r   r)   r   r   r   r   r#   e   s   
 r#   N)Údataclassesr   Útypingr   Útorch.utilsr   Únemo.core.classesr   r   r   Ú__all__r   r	   r#   r   r   r   r   Ú<module>   s   )$