deeppavlov/core/common/metrics_registry.py
def register_metric(metric_name: str) -> Callable[..., Any]:
    """Decorator for metric registration."""
    def decorate(fn):
        fn_name = fn.__module__ + ':' + fn.__name__
        if metric_name in _REGISTRY and _REGISTRY[metric_name] != fn_name:
            log.warning('"{}" is already registered as a metric name, the old function will be ignored'
                        .format(metric_name))
        _REGISTRY[metric_name] = fn_name
        return fn
    return decorate
def register_metric(metric_name: str) -> Callable[..., Any]:
    def decorate(fn):
        fn_name = fn.__module__ + ':' + fn.__name__
        if metric_name in _REGISTRY and _REGISTRY[metric_name] != fn_name:
            log.warning('"{}" is already registered as a metric name, the old function will be ignored'
                        .format(metric_name))
        _REGISTRY[metric_name] = fn_name
        return fn
    return decorate
def register_metric ( metric_name : str ) -> Callable [ ... , Any ] : def decorate ( fn ) : fn_name = fn . __module__ + ':' + fn . __name__ if metric_name in _REGISTRY and _REGISTRY [ metric_name ] != fn_name : log . warning ( '"{}" is already registered as a metric name, the old function will be ignored' . format ( metric_name ) ) _REGISTRY [ metric_name ] = fn_name return fn return decorate
Decorator for metric registration.
Decorator for metric registration .