def get_word_embeddings(model):
    """Gets the word embeddings from a transformer model."""
    for module in model.modules():
        if hasattr(module, 'word_embeddings'):
            return module.word_embeddings
    raise NotImplementedError(
        'Unable to retrieve word embeddings for model. You may need to add a special case to '
        '`get_word_embeddings`.'
    )