In any proceeding under section
1296 or
1346
(g) of this title in which the application of a regulation issued under chapter
5 of title
3 is at issue, the court may review the validity of the regulation in accordance with the provisions of subparagraphs (A) through (D) of section
706
(2) of title
5. If the court determines that the regulation is invalid, the court shall apply, to the extent necessary and appropriate, the most relevant substantive executive agency regulation promulgated to implement the statutory provisions with respect to which the invalid regulation was issued. Except as provided in this section, the validity of regulations issued under this chapter is not subject to judicial review.