Step 1: First you should know which script is added in your amp pages and to check you can validate your pages here https://validator.ampproject.org/ or you can check with chrome extension as well.
Step 2: Once you have figured out which script tag is causing this issue, you have to remove the scrip tag from amp.
Note: Including scripts and java scripts in AMP pages will slow down AMP pages which is negative impact on AMP usage. Now google recommends fast loading pages and this is the main reason why publishers will be using AMP pages even though they have website only for fast loading and better performance on mobile devices.
Step 1: Open AMP for WordPress plugin
Step 2: Go to Design options
Step 3: Click on Global
Step 4: On right side panel scroll down
Step 5: At the bottom you can see Advanced options with custom CSS box.
Step 6: Navigate to NON-AMP version of website and find the class using debugging mode and enter the class name here in AMP box. It will not execute custom script tags, if it is mentioned here.
Step 1: Go to performance in w3 total cache plugin.
Step 2: Now install AMP for WordPress default one.
If you have script tag then only this error will trigger, do a inspect url in search console and debug which script tag is executing
You can visit amp Validator org website and check for errors and fix them or use search console live URL inspection tool both are same.