To the questioner, Please ignore this answer.: it is for others who may come across this question / answer after code to get bmesh elements from their indices, or for those like me who cannot see "not nice" code with out suggesting alteration. Rather than long-commenting added here as an alternate answer.
If we have the indices of vertices can look them up via
bm.verts[index], after calling
bm.verts.ensure_lookup_table() to ensure the indexing. Similarly for edges and faces. Need only loop over indices.
[bm.edges[i] for i in edge_indices]
Looping over every vertex and checking
if v.index == index or worse
if v.index in indices, then appending with
verts = verts + [v] (suggest
verts.append(v)) is both grossly inefficient and s shown, not required.
Use a set for verts in edges to have only one occurrence of each vert. There will be same vert added to list for each connected edge in the list comprehension. Cast it back to a list if need be.
context = bpy.context
ob = context.object
me = ob.data
bm = bmesh.new()
edge_indices = [0, 2, 4]
edges = [bm.edges[i] for i in edge_indices]
all_verts_in_edges = set(v for e in edges for v in e.verts)