code: def _filter_empty_layer_containers(layer_list):
      """Remove empty layer containers."""
      existing = object_identity.ObjectIdentitySet()
      to_visit = layer_list[::-1]
      while to_visit:
          obj = to_visit.pop()
          if obj in existing:
              continue
          existing.add(obj)
          if _is_layer(obj):
              yield obj
          else:
              sub_layers = getattr(obj, "layers", None) or []
  
              # Trackable data structures will not show up in ".layers" lists, but
              # the layers they contain will.
              to_visit.extend(sub_layers[::-1])
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import abc
  import typing
  import six
  import tensorflow
  import tensorflow_probability
  from tf_agents.distributions import utils
  from tf_agents.networks import layer_utils
  from tf_agents.specs import tensor_spec
  from tf_agents.trajectories import time_step
  from tf_agents.typing import types
  from tf_agents.utils import common
  from tf_agents.utils import nest_utils
  from tf_agents.utils import object_identity
  from tensorflow.python.trackable import base
  from tensorflow.python.util import tf_decorator
  from tensorflow.python.util import tf_inspect
label_desc: Use image node_id 2 for calling a global function with example usage: _filter_empty_layer_containers(layer_list) without return types