code: def flatten(seq, container=list):
      """
      >>> list(flatten([1]))
      [1]
      >>> list(flatten([[1, 2], [1, 2]]))
      [1, 2, 1, 2]
      >>> list(flatten([[[1], [2]], [[1], [2]]]))
      [1, 2, 1, 2]
      >>> list(flatten(((1, 2), (1, 2)))) # Don't flatten tuples
      [(1, 2), (1, 2)]
      >>> list(flatten((1, 2, [3, 4]))) # support heterogeneous
      [1, 2, 3, 4]
      """
      if isinstance(seq, str):
          yield seq
      else:
          for item in seq:
              if isinstance(item, container):
                  yield from flatten(item, container=container)
              else:
                  yield item
  
imports: from collections import defaultdict
  from typing import List, Sequence
  from flash.core.utilities.imports import _TOPIC_SERVE_AVAILABLE
label_desc: Use image node_id 9 for calling a global function with example usage: flatten(seq, container) without return types