The conviction of a defendant while mentally incompetent violates due process. See Pate v. Robinson, 383 U.S. 375, 378 (1966). Under 18 U.S.C. § 4241(a), the court must order a competency hearing
...if there is reasonable cause to believe that the defendant may presently be suffering from a mental disease or defect rendering him mentally incompetent to the extent that he is unable to understand the nature and consequences of the proceedings against him or to assist properly in his defense.
18 U.S.C. § 4241(a). A hearing may be ordered on motion by the defendant or the attorney for the Government, or by the court
sua sponte. Id.
Prior to the date of the hearing, the court may order that a psychiatric or psychological examination of the defendant be conducted, and that a psychiatric or psychological report be filed with the court pursuant to the provisions of Section 4247. The hearing itself is conducted according to the procedures set forth at Section 4247(d). These provide that the defendant shall be represented by counsel, and shall have the opportunity to testify, to present evidence, to subpoena witnesses on his or her behalf, and to confront and cross-examine witnesses who appear at the hearing. In determining whether the defendant is competent to stand trial, the court must determine "whether [the defendant] has sufficient present ability to consult with his lawyer with a reasonable degree of rational understanding -- and whether he has a rational as well as factual understanding of the proceedings against him." Dusky v. United States, 362 U.S. 402 (1960).