Happens naturally with consistent meditation night or day when sleeping or meditating very deeply.
It is also possible to train by different techniques, but regardless the basis and foundation is still meditation. Breathing exercises for elevated electricity can stimulate you to become conscious in sleep.
Entering a deep|mild trance on prolonged periods of time while keeping faculty of the fact you are aware of the dream you are seeing without caving in unconscious sleep.
There are also different levels to achieve with this. There are times when you can be fully aware of the time spend sleeping, while having lucid dreams the whole time, in a different perceptive state of course while still resting and being fresh in the morning. Sometimes you can sleep so deeply you are unaware of existence. It relies heavily on natural development, by consistent meditation, happening involuntary and then slowly daily and becoming a routine that isn't even something special anymore, just pleasantly lucid dreaming as it is natural and normal.
The standard is very low with those that do not meditate, but at one point by meditation these things are not even noticed anymore.