I am trying to convert TensorFlow model to PyTorch but having trouble with padding. My code for for relevant platforms are as follow:
TensorFlow
conv1 = tf.layers.conv2d(
                inputs=input_layer,
                filters=32,
                kernel_size=[5, 5],
                padding="same",
                activation=tf.nn.relu,
                name = "conv1")

PyTorch
conv1 = nn.Conv2d(1, 32, kernel_size=5, stride=1, padding=2)

I have few questions:

Are the above codes equivalent?
How many paddings are added on left/right/top/bottom if we use same padding in tensorflow?
How many paddings are added on left/right/top/bottom if we use padding=2 in pytorch?
If the above two code snippets are not equivalent then how can we make the same conv layer?

Thanks in advance.