def compute_metrics(meters):
    """
    Compute averages from meters. Handle tensors vs floats (always return a
    float)
    """
    metrics = {m: vs.avg for m, vs in meters.items()}
    metrics = {m: v if isinstance(v, float) else v.item() for m, v in metrics.items()}
    return metrics