is there any way how to write the following SQL statement in SQLAlchemy ORM:

SELECT AVG(a1) FROM (SELECT sum(irterm.n) AS a1 FROM irterm GROUP BY irterm.item_id);

Thank you

Edit
Report