How to access conv2d inside desne blocks?

For a pretrained model such as densenet161, how can I access one of the conv2d layers inside one of the dense blocks?

You could directly access this layer, e.g. via:

model = models.densenet161()

Generally, you could print the model architecture and use the specified module names to get the wanted layer.