How can I set the avatar in the animator at runtime?

I see from the documentation that I can set/get an avatar in an animator but I do not know how to select the avatar in order to load it. For example I have two models both have an avatar one is maleAvatar the other is femaleAvatar they are both existing in the unity project and humanoids. I have one character controller that has the animator on it and controls model I load into it and manually set the avatar for but how can i do this at runtime or when the player clicks on which gender they would like? I don’t know how to access an avatar to instance it and then use the setter for the animator component.

The game is networked on mirror else i would just create a male and female prefab but seems we should just be able to use that function or am I missing something?

You can make a reference to it in your script: [SerializeField] private Avatar _avatar;
Then you can set the avatar in the inspector and when you need to, change the avatar.