My best guess is that tracing the model didn’t go through the conditions where aux_logits is set to a tensor, so that it stayed None until the return statement. This could happen, e.g. if you called model.eval() before exporting it.