Convolutions with different filter for each feature in the mini-batch wise

I would like to have a 2d convolution with a dynamic filter. I have a input data [B, C, H, W] and 1d kernel [B, H, W, k]. I treat each channel equally and apply the same 1d kernel to each of the channels. my aim is to generate [B, C, H, W] data.
What is the correct way to do this?

Thanks a lot.

To apply a filter to a single input channel, you could use groups=in_channels when creating the nn.Conv2d layer.