Years of practice!
Kobe used to bite from a young age. Yes, it was my fault for not reading him properly (I was new to larger parrots). But it got me researching about behaviour and taking courses. Still I was having a hard time with Kobe. His hormones lasted many months of the year. I am human and I used to get upset, even angry at times at the attacks.... which most probably reinforced more undesired behaviour. But I also saw that many (not all) other people had the same sort of trouble with their male Pionus. Indeed right from the beginning I was advised by an experienced parrot/Pionus owner to get a female.
When we moved house/country 3.5 years ago, the attacks started again. Armed with much more in depth knowledge of ABA I began working with him properly.... noticing exactly what sets him off and avoiding the situation if I can (bit harder in a smaller house when I have to walk towards him at times). At the same time reinforcing any other behaviour. It is much more complicated than that, but from having to carry him on a hand held perch, progressed to a sleeved arm to a bare arm. This year I feel we are making huge progress.
Likewise Kobe used to attack Ollie and Bobbie (Amazons). Bobbie stood her ground - she had to because she couldn't fly. Ollie learned by watching Bobbie and began to stand his ground too. Now the Amazons take no truck from Kobe. But unfortunately Bobbie, now that she has found her wings, will fly to attack Kobe. So I have to be careful with these two out together and try to reinforce their relaxed body language when in the vicinity of each other. Ollie still adores Kobe (Kobe was the only other bird in the household when he arrived scared and untame) and tries to sit near him if he can. I think Kobe is realising Ollie can protect him against Bobbie.
I wouldn't change Kobe for the world though. I love his fiesty character which is also very loving (he tends to follow me everywhere). He is such fun... into everything. Does everything he can to get my attention. The Amazons are so much easier than Kobe.