Actually, reptiles and amphibians and even many fish are known for being able to do this when the demographic winter falls on them. That is, theres no critter of the opposite sex around, and their bodies obviously trigger responses that probably allowed them to survive after the great extinction.
Some of ‘em even change sex.
They’re called transfish.
-happened on my folks farm---