code: def testExtractSignatureOutputsWithPrefix(self):
      signature_def = meta_graph_pb2.SignatureDef()
  
      with tf.Graph().as_default():  # Needed to disable eager mode.
  
          def make_tensor_info(name):
              return tf.compat.v1.saved_model.utils.build_tensor_info(
                  tf.constant(0.0, name=name)
              )
  
          # Test for single entry (non-dict) tensors.
          signature_def.inputs["labels"].CopyFrom(
              make_tensor_info("labels")
          )
  
          signature_def.outputs["predictions"].CopyFrom(
              make_tensor_info("predictions")
          )
          signature_def.outputs["metrics/mean/value"].CopyFrom(
              make_tensor_info("mean_value")
          )
          signature_def.outputs["metrics/mean/update_op"].CopyFrom(
              make_tensor_info("mean_update")
          )
  
          # This case is to check that things like
          # predictions/predictions are okay.
          signature_def.outputs["prefix"].CopyFrom(
              make_tensor_info("prefix")
          )
          signature_def.outputs["prefix1"].CopyFrom(
              make_tensor_info("prefix1")
          )
          signature_def.outputs["prefix2"].CopyFrom(
              make_tensor_info("prefix2")
          )
          signature_def.outputs["prefix/stuff"].CopyFrom(
              make_tensor_info("prefix/stuff")
          )
          signature_def.outputs["prefix/sub/more"].CopyFrom(
              make_tensor_info("prefix/sub/more")
          )
  
          self.assertDictEqual(
              {"__labels": signature_def.inputs["labels"]},
              graph_ref.extract_signature_inputs_or_outputs_with_prefix(
                  "labels", signature_def.inputs, "__labels"
              ),
          )
  
          self.assertDictEqual(
              {"predictions": signature_def.outputs["predictions"]},
              graph_ref.extract_signature_inputs_or_outputs_with_prefix(
                  "predictions", signature_def.outputs
              ),
          )
  
          self.assertDictEqual(
              {
                  "mean/value": signature_def.outputs[
                      "metrics/mean/value"
                  ],
                  "mean/update_op": signature_def.outputs[
                      "metrics/mean/update_op"
                  ],
              },
              graph_ref.extract_signature_inputs_or_outputs_with_prefix(
                  "metrics", signature_def.outputs
              ),
          )
  
          self.assertDictEqual(
              {
                  "prefix": signature_def.outputs["prefix"],
                  "prefix1": signature_def.outputs["prefix1"],
                  "prefix2": signature_def.outputs["prefix2"],
                  "stuff": signature_def.outputs["prefix/stuff"],
                  "sub/more": signature_def.outputs["prefix/sub/more"],
              },
              graph_ref.extract_signature_inputs_or_outputs_with_prefix(
                  "prefix", signature_def.outputs
              ),
          )
  
file_path: model-analysis/tensorflow_model_analysis/eval_saved_model/graph_ref_test.py
imports: import tensorflow
  from tensorflow_model_analysis.eval_saved_model import encoding
  from tensorflow_model_analysis.eval_saved_model import graph_ref
  from tensorflow.core.protobuf import meta_graph_pb2
label_desc: Use image node_id 2 for calling the GraphRefTest obj's underlying member method code with example usage: obj.testExtractSignatureOutputsWithPrefix() and returns: tf