How is the mens sperm collected before the IVF treatment?

Sperm collection. For ivf procedures, the most common method is by mastrubation into a cup on the day of the retrieval. Still, if there are problems with ejaculation or there aren't any sperm in the ejaculate, the collection may require getting and freezing the sperm before the retrieval or by going into the testicle to aspirate the sperm. With all these approaches, healthy sperm can be retrieved for fertilization.
Masturbation. For bovine sperm collections an electric cattle prod is used, however, most men would "object" and healtcare professionals are more "humane", thus men take the collection "into their own hands".