<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _parse_grid(self, grid):
 """Return the input constraints for a Sudoku grid."""

        chars = [c for c in grid if c in DIGITS or c in "0."]
        if len(chars) != 9**2:
            raise ValueError("expected 9x9 grid")
        return [self.litmap[self.X[i // 9 + 1, i % 9 + 1, int(c)]]
                for i, c in enumerate(chars) if c in DIGITS]