The following short excerpt from The Natural Liberation of Becoming by Padmasambhava (Guru Rinpoche) describes very serious Tantric practices that train the consciousness to recognize the true nature of illusory appearances perceived after death, when the consciousness is in the "transitional process" approaching a new birth. The goal of the practitioner is to either avoid birth altogether or seek a fortunate birth that will facilitate continued practice. This once-secret scripture is full of very exacting terminology and cannot be taken lightly. The practices given here are utilized only by highly prepared individuals who are keenly skilled in meditation and other psychological technologies. Yet, the value of this scripture is seen precisely in its clear portrayal of the importance of sex in the liberation of the consciousness from suffering.
These instructions are to be used by someone who has died, thus these instructions are practiced continually in preparation for death. Note that these instructions are written as for a male, but are also taught for females; obviously, the genders should be adjusted as appropriate.
If you see people or animals copulating, or you see a beautiful woman being attracted to you, as soon as passion arises for her, think, "Alas! Having wandered about in the transitional process of becoming, I am preparing to enter a womb. So now I shall close the entrance of the womb."
The scripture describes a series of practices; the first three require the use of imagination: when faced with any scene of passion or sex, the practitioner vividly transforms the scene with their imagination into an event of great purity and devotion, thereby rejecting their own lust. By this method the automatic entrance into a new birth is avoided or transformed. These techniques are taught in order for the consciousness to be trained to be self-aware and free of identification with passion, sensation, and matter, in order for the consciousness to perceive the actual reality (shunyata). As stated repeatedly in the scripture:
This is a time for sincere, pure vision.
The highest method to achieve this mode of consciosness requires a partner, as described in the fourth practice:
Closing the Entrance of the Womb with the Practice of the Four Blisses
Become very well trained in the Great Bliss Instructions on the Lower Orifice [which detail the restraint of the sexual energy], then seek out a qualified mudra [female consort], take her to a solitary place, and meditate on the illusory body of the mudra. Then both you and the mudra should regard yourselves as your chosen deities. First, the practice regarding form entails exchanging brief glances of passion. The practice regarding sound entails romantic words and engagin in speech that rouses passion. The practice regarding smell entails smelling the lotus and the fragrance of the mudra. In terms of taste, bite down and suck on rock sugar and raw sugar. In terms of touch, fondle and suck the breasts, gently embrace and tickle, and rub the center of the lotus. Disrobe and gaze at the vajra and lotus, arouse passion; and when the mudra is intoxicated with desire, passion is aroused, and the vajra is ready, gently offer it into the lotus. After moving it up and down as far as its base, remain in the sense of emptiness for a little while without moving. By moving it gently, without losing that experience, first bliss arises and is recognized. With that sense, remain completely in bliss and emptiness. If it seems like the bliss is vanishing, by moving and thrusting more and more strongly in accord with your experience, pleasure increases and supreme bliss is recognized. Then the primordial wisdom of nondual, inborn bliss and emptiness is recognized.
...as this is a more profound and swift path than other tantras, right now, without worrying about what other people will say, train in the Great Bliss Instructions on the Lower Orifice, for that is the main part of the practice of the transitional process. Thus, it is important to seek out a qualified, youthful consort and train in the profound path of bliss.
How those on the Path of Liberation Close the Entrance of the Womb with the Antidote of Renunciation
Now lay-precept holders, novice monks, or fully ordained monks hwo cherish their vows emphasize meditation on foulness or forcefully practice renunciation as soon as they witness sexual intercourse or recall an object of passion. During the transitional process [after death] when they see a male and female copulating, they will recall their training and renunciation. Either the entrance of the womb will be closed without their entering it, or else they will take birth in a perfect womb and acheive a fortunate rebirth. This path is a bit inferior to the preceeding [path of sexual cooperation].
Excerpted from The Profound Dharma of the Natural Liberation through Contemplating the Peaceful and Wrathful: Stage of Completion Instructions on the Six Bardos by Padmasambhava, dictated to Yeshe Tsogyal (late eighth century Tibet). [Tibetan name: Zab chos zhi khro dgongs pa rang grol gyi rdzogs rim bar do drug gi khrid yg]. Published in English as Natural Liberation (1998) by Wisdom Publications.