Seems like I was not able to run the code because collections.Iterable seems to be deprecated.
I solved the problem by using collections.abc.Iterable according to https://stackoverflow.com/questions/59809785/i-get-a-attributeerror-module-collections-has-no-attribute-iterable-when-i