Let’s say I want to change _bn0 to something else.
from collections import OrderedDict
new_layer = nn.BatchNorm2d(32, eps=0.5)
model.__dict__['_modules'] = OrderedDict([(k, new_layer) if k == '_bn0' else (k, v) for k, v in model.__dict__['_modules'].items()])

But this code need to be changed to accept recursion to change hierarchical layers. In that case, I prefer manual change rather than coding it:
For instance, let’s say we want to change static_padding in first MBConvBlock:
model._blocks[0]._depthwise_conv.static_padding = nn.ZeroPad2d(padding=(2, 2, 2, 2), value=1.1313)


I think there should be better ways as there are different methods to read modules as you have mentioned. But I do not think there is any builtin method for such a case, so you need to program it. If you came up with a code that can generalize this behavior, would be great if you could share.
Bests