How to work with multiple choise of channel configurations?

For example, if I want to make my plugin work in either {1,1}, {2,2} and {4,4} input/output channels, in addition of a side chain input of same channel number, how should I write the plugin bus initialization part?

And if I need to setup my states (such as FFT machine) according to current channel number, how could I get to know the channel configuration change?