At about 6 weeks prenatal, testes start producing testosterone. Hormonal sex is the same for the first 6 weeks prenatal. Prenatal hormones influence development of external genitals, depending on the ratio of estrogens to androgens, and brain dimorphism. Pseudo-hermaphrodites have normal gonads of one sex with ambiguous genitals. The latter occur about 1.5 times per 100,000 births.
Hormonal abnormalities are of several kinds.
He has male gonads but female genitals, leading to a female gender identity. He is sterile, because he has no internal female sexual organs. Although the cause is unknown, it happens in 3 genetic males to every genetic female. There are at least two theories about how children learn gender roles via socialization. Children learn that their behavior has consequences, rewards and punishments.