Your model seems to work fine and creates the same output after restoring:
# Setup
model = resnet20()
data = torch.randn(5, 5, 224, 224)
target = torch.randint(0, 128, (5,))
criterion = nn.CrossEntropyLoss()
optimizer = torch.optim.SGD(model.parameters(), lr=1e-3)

# Train for 10 epochs
for idx in range(10):
    optimizer.zero_grad()
    output = model(data, torch.zeros(data.size(0), 1))
    loss = criterion(output, target)
    loss.backward()
    optimizer.step()
    print('Epoch {}, loss {}'.format(idx, loss.item()))

# Create reference eval output
model.eval()
data = torch.ones(1, 5, 224, 224)
with torch.no_grad():
    output = model(data, torch.zeros(data.size(0), 1))
torch.save({
    'state_dict': model.state_dict(),
    'ref_output': output
    },'ref.pth')


# in new script
model = resnet20()
checkpoint = torch.load('ref.pth')
model.load_state_dict(checkpoint['state_dict'])
ref_output = checkpoint['ref_output']
model.eval()

# Get output for ones
data = torch.ones(1, 5, 224, 224)
with torch.no_grad():
    output = model(data, torch.zeros(data.size(0), 1))

# Compare
print('max abs error: ', (output - ref_output).abs().max())
> max abs error:  tensor(0.)

I cannot check the other code, since some methods are undefined or point to specific data paths.