def METHOD_NAME(
    *,
    ureg: UnitRegistry,
    correct_ans: str,
    comparison: ComparisonType,
    magnitude_partial_credit: Optional[float],
    digits: int,
    rtol: float,
    atol: str,
) -> Callable[[str], Tuple[float, Optional[str]]]:
    parsed_correct_ans = ureg.Quantity(correct_ans)
    parsed_atol = ureg.Quantity(atol)
    def magnitude_comparison_fn(
        submitted_magnitude: float, correct_magnitude: float
    ) -> bool:
        submitted_magnitude_parsed = np.float64(submitted_magnitude)
        correct_magnitude_parsed = np.float64(correct_magnitude)
        """Returns true if submitted_magnitude is close enough to correct_magnitude based on comparison algorithm"""
        if comparison is ComparisonType.EXACT:
            return submitted_magnitude_parsed == correct_magnitude_parsed
        elif comparison is ComparisonType.SIGFIG:
            return pl.is_correct_scalar_sf(
                a_sub=submitted_magnitude_parsed,
                a_tru=correct_magnitude_parsed,
                digits=digits,
            )
        elif comparison is ComparisonType.DECDIG:
            return pl.is_correct_scalar_dd(
                a_sub=submitted_magnitude_parsed,
                a_tru=correct_magnitude_parsed,
                digits=digits,
            )
        elif comparison is ComparisonType.RELABS:
            return pl.is_correct_scalar_ra(
                a_sub=submitted_magnitude_parsed,
                a_tru=correct_magnitude_parsed,
                rtol=rtol,
                atol=parsed_atol.magnitude,
            )
        assert_never(comparison)
    magnitudes_match_credit = (
        magnitude_partial_credit if magnitude_partial_credit is not None else 0.0
    )
    units_match_credit = (
        (1.0 - magnitude_partial_credit)
        if magnitude_partial_credit is not None
        else 0.0
    )
    def grade_exact_units(submitted_ans: str) -> Tuple[float, Optional[str]]:
        # will return no error, assuming parse() catches all of them
        parsed_submission = ureg.Quantity(submitted_ans)
        magnitudes_match = magnitude_comparison_fn(
            parsed_submission.magnitude, parsed_correct_ans.magnitude
        )
        units_match = parsed_correct_ans.units == parsed_submission.units
        if magnitudes_match and units_match:
            return 1.0, None
        elif magnitudes_match and not units_match:
            return magnitudes_match_credit, INCORRECT_UNITS_CORRECT_MAGNITUDE_FEEDBACK
        elif units_match and not magnitudes_match:
            return units_match_credit, CORRECT_UNITS_INCORRECT_MAGNITUDE_FEEDBACK
        return 0.0, INCORRECT_UNITS_AND_MAGNITUDE_FEEDBACK
    return grade_exact_units