Implement the Noisy Top-K gating mechanism used in Mixture-of-Experts (MoE) models. Given an input matrix, weight matrices, pre-sampled noise, and a sparsity constraint k, compute the final gating probabilities matrix.
First compute the noisy gate scores
Then, in each row of , keep the largest entries, set all others to , and apply a softmax over the row. Return a NumPy array of shape (batch_size, num_experts); each row has non-zero probabilities that sum to 1.