[docs]defcast_metrics(metrics:Union[List[str],List[Dict]],)->Tuple[List[str],List[Dict[str,Any]]]:""" Turn metrics to list of metric names and parameter list. :param metrics: List of string or dictionary. :return: The list of metric names and dictionary list of metric parameters. """metrics_copy=deepcopy(metrics)ifnotisinstance(metrics_copy,list):raiseValueError("metrics must be a list of string or dictionary.")ifisinstance(metrics_copy[0],str):returnmetrics_copy,[{}for_inmetrics_copy]elifisinstance(metrics_copy[0],dict):# pop 'metric_name' key from dictionarymetric_names=list(map(lambdax:x.pop("metric_name"),metrics_copy))metric_params=[dict(map(lambdax,y:cast_embedding_model(x,y),metric.keys(),metric.values(),))formetricinmetrics_copy]returnmetric_names,metric_paramselse:raiseValueError("metrics must be a list of string or dictionary.")