U
    <A·fh  ã                   @   sD   d dl mZ d dlm  mZ d dlmZmZ G dd„ dejƒZ	dS )é    )ÚDictN)ÚTensorÚnnc                       sf   e Zd ZdZddœ‡ fdd„Zeeef eeef dœdd„Zddœd	d
„Z	e
d dœdd„ƒZ‡  ZS )Ú	Normalizez/This layer normalizes embeddings to unit lengthN)Úreturnc                    s   t t| ƒ ¡  d S ©N)Úsuperr   Ú__init__)Úself©Ú	__class__© úJ/tmp/pip-unpacked-wheel-i7fohqg6/sentence_transformers/models/Normalize.pyr	   
   s    zNormalize.__init__)Úfeaturesr   c                 C   s"   |  dtj|d dddi¡ |S )NZsentence_embeddingé   é   )ÚpZdim)ÚupdateÚFÚ	normalize)r
   r   r   r   r   Úforward   s    zNormalize.forwardc                 C   s   d S r   r   )r
   Zoutput_pathr   r   r   Úsave   s    zNormalize.savec                 C   s   t ƒ S r   )r   )Z
input_pathr   r   r   Úload   s    zNormalize.load)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r	   r   Ústrr   r   r   Ústaticmethodr   Ú__classcell__r   r   r   r   r      s    r   )
Útypingr   Ztorch.nn.functionalr   Z
functionalr   Ztorchr   ÚModuler   r   r   r   r   Ú<module>   s   