You have to apply a different 2d filter on each of the M input’s channels I_m, let say you obtain M filtered maps F_m. Then each of the N output’s channels O_n is a different linear combination of these F_m.
I don’t see how to avoid a loop over the input’s channels, applying M times nn.Conv2d(1,1). Then applying the N linear combinations may be done by a single matrix multiplication.