code: def list_all_layers(obj):
      if isinstance(obj, training_lib.Model):
          # Handle special case of Sequential, which doesn't return
          # the `Input` layer.
          return obj.layers
      else:
          return list(
              obj._flatten_layers(include_self=False, recursive=False)
          )
  
imports: import itertools
  import threading
  import types
  from tensorflow.python.eager import context
  from tensorflow.python.keras import backend
  from tensorflow.python.keras.engine import base_layer_utils
  from tensorflow.python.keras.utils import control_flow_util
  from tensorflow.python.keras.utils import tf_contextlib
  from tensorflow.python.keras.utils import tf_inspect
  from tensorflow.python.keras.utils.generic_utils import LazyLoader
  from tensorflow.python.util import tf_decorator
label_desc: Use image node_id 3 for calling a global function with example usage: list_all_layers(obj) and returns: obj, list