last post a bit more, I realised that there were a few things that I should have mentioned in my essay but didn't.
What I stated as fact about brain sex being determined before birth is the leading current theory, which has come from extensive research. It's not just something that I've plucked out of the air. If you're interested, I'm sure that your favourite search engine could turn up links to such research.
What I call brain sex is often called gender identity. Because physical sex and brain sex are both fixed before birth but gender is a social construct, I much prefer the clearer distinction created by using one term for the two fixed characteristics and a different term for the social construct. I don't think that the term gender identity provides the same level of clarity, as it associates a brain trait established before birth with a social construct in a way that could be used by some anti-transgender (generally churchianity) groups who tend to claim that being transgender is a choice.
Clearly, the research indicates that it is not.
There is another thing that is also established in the brain prior to birth, which hate groups tend to also try to claim is a choice. Sexual orientation.
Like brain sex, sexual orientation is a continuum from being attracted only to males through being equally attracted to both sexes to being only attracted to females, with a sizeable area of attraction to various transgender or intersex people that makes it impossible to illustrate it as a line.
Sexual orientation is completely separate from brain sex. Yes, you probably read that right. Who you are sexually attracted to is completely independent of the sex that you identify as.
The theory of brain sex and sexual orientation being independent but both being determined before birth explains not only heterosexuality, homosexuality and bisexuality in cisgender people (people whose brain sex and hence gender role matches their physical sex), but also explains the same range of sexual orientation variations in transgender people.
The part about the relationship between brain sex and sexual orientation that most people struggle with is the fact that most people think in terms of heterosexual and homosexual. A person whose position on the gender spectrum shifts, whether temporarily or permanently, throws that whole concept into disarray.
Fortunately, there are a couple of concepts that solve this problem quite neatly, and can also be viably applied to cisgender people. They are gynephilia and androphilia. These two terms define who a person is attracted to without reference to who they are. Gynephilia is attraction to females, while androphilia is attraction to males. There are also, of course, bisexual, asexual (not sexually attracted to anybody) and narcissistic (sexually attracted to themselves ~ I'd say "eww" here but I'd probably offend someone :-P ).
So, for example, my gender role tends to vary between male and female, but I always remain gynephilic.
Occasionally, people claim to have changed their sexual orientation at the same time as changing gender role. In practise, in the long term most will admit that they are in fact revealing their true sexual orientation, having pretended otherwise to fit into social expectations.
I believe that western societies are gradually becoming more accepting of both gender variations and variations in sexual orientation, and provided that we don't experience any radical social lurches towards religious fundamentalism, I foresee a time when children will be comfortable being open and honest about who they are and who they are attracted to, instead of having to waste years struggling to be someone who others expect them to be. The benefits to the individuals and to the community as a whole are enormous.