code: def _infer_state_specs(
      layers: Sequence[tf.keras.layers.Layer],
  ) -> Tuple[types.NestedTensorSpec, List[bool]]:
      """Infer the state spec of a sequence of keras Layers and Networks.
  
      Args:
        layers: A list of Keras layers and Network.
  
      Returns:
        A tuple with `state_spec`, a tuple of the state specs of length
        `len(layers)` and a list of bools indicating if the corresponding layer
        has lists in it's state.
      """
      state_specs = []
      layer_state_is_list = []
      for layer in layers:
          spec = network.get_state_spec(layer)
          if isinstance(spec, list):
              layer_state_is_list.append(True)
              state_specs.append(tuple(spec))
          else:
              state_specs.append(spec)
              layer_state_is_list.append(False)
  
      return tuple(state_specs), layer_state_is_list
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import copy
  from typing import Any, List, Mapping, Optional, Sequence, Text, Tuple, Union
  import tensorflow
  from tf_agents.keras_layers import rnn_wrapper
  from tf_agents.networks import network
  from tf_agents.typing import types
  from tf_agents.utils import common
label_desc: Use image node_id 1 for calling a global function with example usage: _infer_state_specs(layers) and returns: tuple,  layer_state_is_list