acoder_acoder:

In the forward() function, though _transform_input() is called, it does nothing for the input. Since a parameter transform_input is controlling whether to use the transform function.


Since this attribute is set to True in your example, the input will be transformed.
Using it also yields the same results:
x = torch.randn(10, 3, 224, 224)
glnet = models.googlenet(pretrained=True)
glnet.eval()
res = glnet(x)

out = x
if glnet.transform_input:
    out = glnet._transform_input(out)
for name, layer in glnet.named_children():
    if name == 'fc':
        out = nn.Flatten()(out)
    out = layer(out)

print((out - res).abs().max())
> tensor(0., grad_fn=<MaxBackward1>)