Sure, just get rid of “array of layers” (and then of loop). As linear layer only does fused.matmul(W) + B, create (batched) W and B instead - nn.Embedding may be appropriate for that.
I should add that matmul will probably need to be replaced with torch.bmm (shapes (B,1,in) @ (B,in,out) = (B,1,out))