How to Hide AI Image Generator Admin Menus

function plt_hide_ai_image_generator_menus() {
	//Hide the "Media → AI Image Generator" menu.
	remove_submenu_page('upload.php', 'ai-wp-cgntvdnmc');
	//Hide the "Media → Upgrade" menu.
	remove_submenu_page('upload.php', 'ai-wp-cgntvdnmc-pricing');
}

add_action('admin_menu', 'plt_hide_ai_image_generator_menus', 1000000000);

Where do I put this code?