def METHOD_NAME(engine, outputs, labels):
    assert isinstance(outputs,
                      (torch.Tensor, list, tuple,
                       dict)), f'Expect output of model is (torch.Tensor, list, tuple), got {type(outputs)}'
    if isinstance(outputs, torch.Tensor):
        outputs = (outputs,)
    if isinstance(labels, torch.Tensor):
        labels = (labels,)
    if isinstance(outputs, (tuple, list)) and isinstance(labels, (tuple, list)):
        return engine.criterion(*outputs, *labels)
    elif isinstance(outputs, (tuple, list)) and isinstance(labels, dict):
        return engine.criterion(*outputs, **labels)
    elif isinstance(outputs, dict) and isinstance(labels, dict):
        return engine.criterion(**outputs, **labels)
    elif isinstance(outputs, dict) and isinstance(labels, (list, tuple)):
        raise ValueError(f"Expected labels to be a dict when the model outputs are dict, but got {type(labels)}")
    else:
        raise TypeError(f"Expected model outputs and labels to be of type torch.Tensor ' \
            '(which is auto-converted to tuple), list, tuple, or dict, ' \
            'but got {type(outputs)} (model outputs) and {type(labels)} (labels)")