o
    èp©ió  ã                   @   s,   d dl mZ d dlmZ G dd„ deƒZdS )é   )Úcommon_functions)Ú#ModuleWithRecordsReducerAndDistancec                   @   s   e Zd Zdd„ Zdd„ ZdS )ÚBaseRegularizerc                 C   s   t ‚)N)ÚNotImplementedError)ÚselfÚx© r   úi/home/ubuntu/.local/lib/python3.10/site-packages/pytorch_metric_learning/regularizers/base_regularizer.pyÚcompute_loss   s   zBaseRegularizer.compute_lossc                 C   s&   |   ¡  |  |¡}|  ||t |¡¡S )z9
        x should have shape (N, embedding_size)
        )Úreset_statsr
   ÚreducerÚc_fÚtorch_arange_from_size)r   r   Ú	loss_dictr   r   r	   Úforward	   s   
zBaseRegularizer.forwardN)Ú__name__Ú
__module__Ú__qualname__r
   r   r   r   r   r	   r      s    r   N)Úutilsr   r   Ú%utils.module_with_records_and_reducerr   r   r   r   r   r	   Ú<module>   s    