You could directly access this layer, e.g. via:
model = models.densenet161()
model.features.denseblock4.denselayer21.conv2

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