Your definition of gender is somewhat behind the times. Humans come off the assembly line in five flavors. Male, female, and three types of hermaphrodites, each recognized as a separate gender. The three types of hermaphrodites are recognized as being equally male and female, or mainly male, or mainly female. I don't recall
if that's defined by what functions or the gross anatomy, but that's the modern definition of it. At least, here in the US for over a decade now, and apparently in the global scientific/medical communities. Which a local town GP may not quite agree with.
Transsexuals are something else again, the vote is still split on how to classify them for what purposes.
And, it's not just an X/vs/Y chromosome thing, there are other variations in the chromosomes besides the "usual" male and female.
Brings new and frightening potential to the question of what a Scotsman wears under his kilt.<G>