code: def _infer_state_dtype(explicit_dtype, state):
      """Infer the dtype of an RNN state.
  
      Args:
        explicit_dtype: explicitly declared dtype or None.
        state: RNN's hidden state. Must be a Tensor or a nested iterable containing
          Tensors.
  
      Returns:
        dtype: inferred dtype of hidden state.
  
      Raises:
        ValueError: if `state` has heterogeneous dtypes or is empty.
      """
      if explicit_dtype is not None:
          return explicit_dtype
      elif nest.is_sequence(state):
          inferred_dtypes = [
              element.dtype for element in nest.flatten(state)
          ]
          if not inferred_dtypes:
              invalidInputError(
                  False, "Unable to infer dtype from empty state."
              )
          all_same = all(
              [x == inferred_dtypes[0] for x in inferred_dtypes]
          )
          if not all_same:
              invalidInputError(
                  False,
                  "State has tensors of different inferred_dtypes. Unable to infer a "
                  "single representative dtype.",
              )
          return inferred_dtypes[0]
      else:
          return state.dtype
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor_shape
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import control_flow_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import rnn_cell_impl
  from tensorflow.python.ops import tensor_array_ops
  from tensorflow.python.ops import variable_scope
  from tensorflow.python.util import nest
  from bigdl.dllib.utils.log4Error import *
label_desc: Use image node_id 3 for calling a global function with example usage: _infer_state_dtype(explicit_dtype, state) and returns: explicit_dtype, inferred_dtypes, state