Two-Loop Superstrings. VII. Cohomology of Chiral Amplitudes