def error_details()

in compiler_gym/validation_result.py [0:0]


    def error_details(self) -> str:
        """A summary description of the validation errors."""
        if not self.errors:
            return ""

        msg = []
        error_types = [e.type for e in self.errors]
        freq = sorted(Counter(error_types).items(), key=lambda x: -x[1])

        # Shortcut for when there is just a single message to aggregate. Use
        # format: "${error_msg}" if there is a single error or "${n}×
        # ${error_msg}" if there are multiple copies of the same error.
        if len(freq) == 1:
            message = str(error_types[0])
            if len(error_types) == 1:
                return message
            return f"{len(error_types)}× {message}"

        # If there are multiple error messages, number them using the format:
        # "[${i}/${j}] ${n}× ${error_msg}". E.g. "[1/3] 18× Memory leak".
        for j, (message, count) in enumerate(freq, start=1):
            if count > 1:
                msg.append(f"[{j}/{len(freq)}] {count}× {message}")
            else:
                msg.append(f"[{j}/{len(freq)}] {message}")
            remaining = len(freq) - j
            if j >= 3 and remaining > 3:
                msg.append(
                    f"... ({remaining} more {plural(remaining, 'error', 'errors')})"
                )
                break
        return ", ".join(msg)