You could use e.g .map to compare the paired elements in both containers.
Also, note that the == operation is usually not recommended for floating point numbers, to you should use torch.allclose, if applicable:
lista = [torch.randn(1) for _ in range(5)]
listb = [a+1e-6 for a in lista]

all(map(lambda x, y: torch.allclose(x, y), lista, listb))
> True




 joschnei:

As an aside, does anyone know why it was decided to implement == this way, instead of having == return a bool and having a different elementwise equality?


Most likely to stick to the numpy API, which yields the same output.