Double check for attribute num_examples
# What does this PR do?

As pointed out by #12479, the `isinstance` check for `IterableDataset` and its subclasses does not look at the type, but whether the class implements some methods, but not all attributes. This PR adds a double check when necessary to avoid an `AttributeError`.

Fixes #12479
Failure looks unrelated but circleCI is not letting me re-run the tests, so merging and watching master.