(a) Except as provided in subsection (b), and except for a person delivered to authorities of a foreign country under section 3263, a person arrested for or charged with a violation of section 3261(a) shall not be removed—
(b) The limitation in subsection (a) does not apply if—
a Federal magistrate judge orders the person to be removed to the United States to be present at a detention hearing held pursuant to section 3142(f);
a Federal magistrate judge orders the detention of the person before trial pursuant to section 3142(e), in which case the person shall be promptly removed to the United States for purposes of such detention;
the person is entitled to, and does not waive, a preliminary examination under the Federal Rules of Criminal Procedure, in which case the person shall be removed to the United States in time for such examination;
the Secretary of Defense determines that military necessity requires that the limitations in subsection (a) be waived, in which case the person shall be removed to the nearest United States military installation outside the United States adequate to detain the person and to facilitate the initial appearance described in section 3265(a).