Implement a Mixture-of-Experts (MoE) layer using softmax gating and top-k routing. Given an input tensor, a set of expert weight matrices, a gating weight matrix, and parameters specifying the number of experts and the value of k, compute the final MoE output by selecting the top-k experts per token, applying their transformations, and aggregating the results weighted by the normalized gating probabilities.
Conventions the tests rely on, for each token (a row vector of length d_model):
x @ Wg; the gating probabilities are their softmax over all n_experts experts.top_k largest probabilities and renormalize them so they sum to 1.x @ We[i].Return a float array of shape (n_batch, l_seq, d_model).