Project: 057_The_Geometry_of_Categorical_and_Hierarchical_Conce | Function: estimate_single_dir_from_embeddings (iclr)

system: You are an expert Python programmer implementing algorithms from scientific papers.
Complete the masked function based on the algorithm description.
Follow Python best practices and maintain consistent code style.
Return **only** the complete Python function code.

user: Complete this Python function:

**DESCRIPTION:** Implements Linear Discriminant Analysis (LDA) based estimation of vector representations for binary features. This function computes the optimal direction that separates concept embeddings from the rest of vocabulary while minimizing within-class variance.

**KEY TERMS:** {
  "category_embeddings": "gw",
  "category_mean": "E(gw)",
  "pseudo_inv": "Cov(gw)^†",
  "lda_dir": "ℓ̄w"
}

**CONTEXT CODE:** import json
import networkx as nx

import torch
from sklearn.covariance import ledoit_wolf


def get_categories(noun_or_verb = 'noun', model_name = 'gemma'):

    raise NotImplementedError("Function implementation has been masked for testing")

def category_to_indices(category, vocab_dict):
    return [vocab_dict[w] for w in category]

def get_words_sim_to_vec(query: torch.tensor, unembed, vocab_list, k=300):
    similar_indices = torch.topk(unembed @ query, k, largest=True).indices.cpu().numpy()
    return [vocab_list[idx] for idx in similar_indices]

def estimate_single_dir_from_embeddings(category_embeddings):
    raise NotImplementedError("Function implementation has been masked for testing")

def estimate_cat_dir(category_lemmas, unembed, vocab_dict):
    category_embeddings = unembed[category_to_indices(category_lemmas, vocab_dict)]
    lda_dir, category_mean = estimate_single_dir_from_embeddings(category_embeddings)
    
    return {'lda': lda_dir, 'mean': category_mean}



import inflect
p = inflect.engine()

def noun_to_gemma_vocab_elements(word, vocab_set):
    word = word.lower()
    plural = p.plural(word)
    add_cap_and_plural = [word, word.capitalize(), plural, plural.capitalize()]
    add_space = ["▁" + w for w in add_cap_and_plural]
    return vocab_set.intersection(add_space)


def get_animal_category(data, categories, vocab_dict, g):
    vocab_set = set(vocab_dict.keys())

    animals = {}
    animals_ind = {}
    animals_g = {}
    animals_token = {}

    for category in categories:
        animals[category] = []
        animals_ind[category] = []
        animals_g[category] = []
        animals_token[category] = []

    for category in categories:
        lemmas = data[category]
        for w in lemmas:
            animals[category].extend(noun_to_gemma_vocab_elements(w, vocab_set))
        
        for word in animals[category]:
            animals_ind[category].append(vocab_dict[word])
            animals_token[category].append(word)
            animals_g[category] = g[animals_ind[category]]
    return animals_token, animals_ind, animals_g

Complete the function implementation replacing "raise NotImplementedError".