class_docstr: Tests KerasLayer in an all-Keras environment.
class_docstr_tok: ["Tests","KerasLayer","in","an","all-Keras","environment","."]
docstr: Tests use of input/output dicts.
docstr_tok: ["Tests","use","of","input\/output","dicts","."]
code: def testInputOutputDict(self, pass_output_shapes):
      """Tests use of input/output dicts."""
      # Create a SavedModel to compute sigma=[x+y, x+2y] and maybe delta=x-y.
      export_dir = os.path.join(self.get_temp_dir(), "with-dicts")
      _save_model_with_dict_input_output(export_dir)
      # Build a Model from it using Keras' "functional" API.
      x_in = tf_keras_v2.layers.Input(shape=(1,), dtype=tf.float32)
      y_in = tf_keras_v2.layers.Input(shape=(1,), dtype=tf.float32)
      dict_in = dict(x=x_in, y=y_in)
      kwargs = dict(
          arguments=dict(return_dict=True)
      )  # For the SavedModel.
      if pass_output_shapes:
          # Shape inference works without this, but we pass it anyways to exercise
          # that code path and see that map_structure is called correctly
          # and calls Tensor.set_shape() with compatible values.
          kwargs["output_shape"] = dict(sigma=(2,), delta=(1,))
      imported = hub.KerasLayer(export_dir, **kwargs)
      dict_out = imported(dict_in)
      delta_out = dict_out["delta"]
      sigma_out = dict_out["sigma"]
      concat_out = tf_keras_v2.layers.concatenate(
          [delta_out, sigma_out]
      )
      model = tf_keras_v2.Model(
          dict_in, [delta_out, sigma_out, concat_out]
      )
      # Test the model.
      x = np.array([[11.0], [22.0], [33.0]], dtype=np.float32)
      y = np.array([[1.0], [2.0], [3.0]], dtype=np.float32)
      outputs = model(dict(x=x, y=y))
      self.assertLen(outputs, 3)
      delta, sigma, concat = [x.numpy() for x in outputs]
      self.assertAllClose(delta, np.array([[10.0], [20.0], [30.0]]))
      self.assertAllClose(
          sigma, np.array([[12.0, 13.0], [24.0, 26.0], [36.0, 39.0]])
      )
      self.assertAllClose(
          concat,
          np.array(
              [
                  [10.0, 12.0, 13.0],
                  [20.0, 24.0, 26.0],
                  [30.0, 36.0, 39.0],
              ]
          ),
      )
      # Test round-trip through config.
      config = imported.get_config()
      new_layer = hub.KerasLayer.from_config(_json_cycle(config))
      if pass_output_shapes:
          self.assertEqual(
              new_layer._output_shape, imported._output_shape
          )
      else:
          self.assertFalse(hasattr(new_layer, "_output_shape"))
  
imports: import json
  import os
  from absl.testing import parameterized
  import numpy
  import tensorflow
  import tensorflow_hub
label_desc: Use image node_id 6 for calling the KerasTest obj's underlying member method code with example usage: obj.testInputOutputDict(pass_output_shapes) without return types