aggregate_metric_classes is needed in this line:
 elif metric_type in aggregate_metric_classes:       #aggregate metrics