"""Class for base embedder."""

# AUTOGENERATED! DO NOT EDIT! File to edit: ../../../src/models/embedding/base_embedder.ipynb.

# %% auto #0
__all__ = ['BaseEmbedder']

# %% ../../../src/models/embedding/base_embedder.ipynb #7db9efd6-abbc-4256-b0d9-7f7da64d81b4
from ...imports import *
from ..config_model import ConfigModel

# %% ../../../src/models/embedding/base_embedder.ipynb #c245730f-dc67-4209-8ae5-d5080da0e362
class BaseEmbedder(ConfigModel, abc.ABC):
    def __init__(self) -> None: 
        super().__init__()  

        # Note: While using DDP with huggingface-Accelerate we noticed
        # the fixed weights didn't get synced if there is no parameter
        # that requires a gradient. So we add a dummy to make sure
        # all model instances/nodes have the same embedder!
        self.dummy_parameter = torch.tensor(0.0)
        self.dummy_parameter = nn.Parameter(self.dummy_parameter)

    def forward(self, *args, **kwargs): 
        return self.embed(*args, **kwargs)
    
    @abc.abstractmethod
    def embed(self, x): pass
        
    @abc.abstractmethod
    def invert(self, x): pass
