This library contains class what converts html to AMP.
Work in progress
pip install amp_tools
from amp_tools import TransformHtmlToAmp
html_elements = '<span class="test-class">' \
'<form class="form-test"></form>' \
'<img src="media/test.png" width="300" height="220">' \
'</span>'
valid_amp = TransformHtmlToAmp(html_elements)()
# Return
b'<div class="amp-text"><amp-img src="media/test.png" width="300" height="220" layout="responsive"></amp-img></div>'