import torch


def embedding(model, data):
    """
    Compute embedding for model and data

    Args:
        model: input model
        data: network

    Returns:
        embedding coords for nodes

    This function switches the model to eval state before computing the embedding and restores the original
    training state of the model

    """
    train_state = model.training
    model.training = False
    with torch.no_grad():
        coords = model.encode(data)
    model.training = train_state
    return coords