code: def check_deterministic(iterable):
      # Most places where OrderedSet is used, pytensor interprets any exception
      # whatsoever as a problem that an optimization introduced into the graph.
      # If I raise a TypeError when the DestroyHandler tries to do something
      # non-deterministic, it will just result in optimizations getting ignored.
      # So I must use an assert here. In the long term we should fix the rest of
      # pytensor to use exceptions correctly, so that this can be a TypeError.
      if iterable is not None:
          if not isinstance(
              iterable,
              (list, tuple, OrderedSet, types.GeneratorType, str, dict),
          ):
              if len(iterable) > 1:
                  # We need to accept length 1 size to allow unpickle in tests.
                  raise AssertionError(
                      "Get an not ordered iterable when one was expected"
                  )
  
imports: import types
  import weakref
  from collections.abc import MutableSet
label_desc: Use image node_id 1 for calling a global function with example usage: check_deterministic(iterable) without return types