In a Mixture-of-Experts (MoE) layer, each input token must be dispatched to one of several expert networks. Instead of using a learned gating network, hash-based routing assigns each token to an expert purely as a deterministic function of the token's ID. This removes the need for training a router and guarantees a fixed, reproducible assignment.
You are given a 1D array of integer token IDs, a 2D array of token embeddings (shape (N, d)), a list of expert weight matrices (each of shape (d, d_out)), and the number of experts E.
Implement a function that:
(token_id mod E).The mapping must be deterministic and depend only on the token ID, not the embedding values.