How does a forensic psychologist determine a defendant’s mental competence?

Forensic psychologists deal with two particularly controversial issues: judging whether a defendant is competent to stand trial and whether a defendant was legally insane at the time he or she committed an offense. Both issues require evaluations of the defendant’s mental state. A defendant is deemed competent to stand trial if he or she has the ability to function with full awareness and understanding in a trial. If a defendant cannot assist in his or her own defense, or does not understand the legal proceedings, he or she usually is declared incompetent. How does a forensic psychologist determine a defendant’s mental competence? Does mental illness or mental retardation automatically signify a defendant is incompetent? What if a defendant is competent with medication, but incompetent without it?