def METHOD_NAME(verts: list, faces: list, mesh: bpy.types.Mesh, uv_name: str, matrix=None):
    with bmesh_from_edit_mesh(mesh) as bm:
        uv_layer = bm.loops.layers.uv.get(uv_name)
        for f, bmf in zip(repeat_last(faces), bm.faces):
            for i, bml in zip(repeat_last(f), bmf.loops):
                co = verts[i]
                uv = Vector(co[:2]) if matrix is None else (matrix @ Vector(co))[:2]
                bml[uv_layer].uv = uv