gh-35650: Fix bug caused by cached representation in cohomology classes
### :books: Description
Fixes #35649
Adds the parent to the creation of cohomology classes, so they are not
confused between different parents.
### :memo: Checklist
- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation accordingly.
### :hourglass: Dependencies
URL: https://github.com/sagemath/sage/pull/35650
Reported by: miguelmarco
Reviewer(s): Matthias Köppe, miguelmarco, Travis Scrimshaw