def get_loss_and_metrics(fcn, **kwargs):
    """Get both loss and metrics from a callable."""
    
    loss = fcn(**kwargs)
    metrics = {}
    
    if isinstance(loss, dict):
        metrics = loss.get('metrics', {})
        loss = loss['loss']
    
    return loss, metrics