Rewriting Tf to Pytorch DepthwiseConv2d functor opperation

Hello, In my research I have to rewrite the following function to Pytorch. The project involves looping over the layers in the network. Does anyone know how to rewrite the following:

depthwise = DepthWiseConv2d(in_channels = inp.shape[2], out_channels = out.shape[2], kernel_size = kernel, padding=padding, stride=stride, dilation = dilation_rate)
functor = K.function([inp, K.learning_phase()], [depthwise])
depthwise_conv2d_vals = functor([test_ex, 0])[0]

I don’t know what a functor is in TF/Keras, but would assume that you could just create the nn.Conv2d layer in PyTorch and pass the input directly to it.
If that’s not the case, could you explain what this code is doing?

Thank you for the reply, it is already fixed. So this topic could be removed.