When diagnosing pages within AMP, the line number results are determined based upon the line number in the source of the document as tested. This line number should match (or closely correspond to) the line number for the violating code when viewing the generated source.
When testing against a saved module source file (which often is merely a snippet of the page), the results are also based upon the line number within the source. The difference, of course, is that this does not correspond to that code’s position within the full document source.
On a practical level, today’s websites are not built as static and complete pages. Pages within modern websites are often, at minimum, built using template-driven interfaces assembled at request time using methods of including one or more files in another. This means that typically, providing exact line numbers of the violating code probably won’t map specifically to the developer's code level implementation on the screen. In these instances the developer would need to work to determine what the code level source of the violation is.