def match(cls, responses, targets, timeout_duration=15) -> int:
        """Whether two LaTeX expressions are equal."""
        if not isinstance(responses, str) or not isinstance(targets, str):
            return 0
        signal.signal(signal.SIGALRM, timeout_handler)
        signal.alarm(timeout_duration)  # Set the timeout duration in seconds
        try:
            # seems that this eval can get stuck when evaluating all tasks..
            responses = normalize_latex(responses)
            targets = normalize_latex(targets)
            responses_expr = parse_latex(responses)
            targets_expr = parse_latex(targets)
            result = 1 if responses_expr.equals(targets_expr) else 0
            return result
        except (
            LaTeXParsingError,
            SympifyError,
            TypeError,
            TimeoutException,
            NotImplementedError,
        ):
            return SimpleStrMatch.match(responses, targets)
        finally:
            signal.alarm(0)  # Cancel the alarm if it completes successfully
Whether two LaTeX expressions are equal.
vlmeval/dataset/utils/megabench/scoring/latex_expr_equality.py