import numpy as np

def compute_processed_metrics(metric_func, train_greedy_texts, train_target_texts, train_input_texts, aggregated: bool = False):
    processed_train_target_texts = []
    for y in train_target_texts:
        ### for OOD experiments
        if isinstance(y, list) and (not aggregated):
            y_ = y[0]
        elif isinstance(y, str) and (aggregated):
            y_ = [y]
        else:
            y_ = y
        processed_train_target_texts.append(y_)

    seq_metrics = metric_func({"greedy_texts": train_greedy_texts, "target_texts": processed_train_target_texts, "input_texts": train_input_texts}, 
                              processed_train_target_texts)        
    seq_metrics[np.isnan(seq_metrics)] = 0
    return seq_metrics