class_docstr: Tests the Python interface to recomputation rewrites.
  
  See core/grappler/optimizers/memory_optimizer_test.cc for functional tests.
class_docstr_tok: ["Tests","the","Python","interface","to","recomputation","rewrites",".","See","core\/grappler\/optimizers\/memory_optimizer_test.cc","for","functional","tests","."]
code: def _annotated_graph(self):
      graph = ops.Graph()
      with graph.as_default():
          random_seed.set_random_seed(2)
          current_activation = variable_scope.get_variable(
              name="start", shape=[1, 2, 2, 5]
          )
          conv_filter = variable_scope.get_variable(
              name="filter", shape=[5, 5, 5, 5]
          )
          for layer_number in range(3):
              with variable_scope.variable_scope(
                  "layer_{}".format(layer_number)
              ):
                  after_conv = nn.conv2d(
                      current_activation,
                      conv_filter,
                      [1, 1, 1, 1],
                      "SAME",
                  )
                  current_activation = 2.0 * after_conv
                  current_activation.op._set_attr(
                      "_recompute_hint",
                      # The value of the attribute does not matter; just that the key
                      # exists in the op's attributes.
                      attr_value_pb2.AttrValue(i=1),
                  )
                  current_activation += 5.0
                  current_activation.op._set_attr(
                      "_recompute_hint", attr_value_pb2.AttrValue(i=0)
                  )
                  current_activation = nn.relu(current_activation)
                  current_activation.op._set_attr(
                      "_recompute_hint", attr_value_pb2.AttrValue(i=1)
                  )
          loss = math_ops.reduce_mean(current_activation)
          optimizer = train.AdamOptimizer(0.001)
          train_op = optimizer.minimize(loss)
          init_op = variables.global_variables_initializer()
      return graph, init_op, train_op
  
imports: from tensorflow.core.framework import attr_value_pb2
  from tensorflow.core.protobuf import config_pb2
  from tensorflow.core.protobuf import rewriter_config_pb2
  from tensorflow.python.client import session
  from tensorflow.python.framework import meta_graph
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import random_seed
  from tensorflow.python.framework import test_util
  from tensorflow.python.grappler import tf_optimizer
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import nn
  from tensorflow.python.ops import variable_scope
  from tensorflow.python.ops import variable_v1
  from tensorflow.python.ops import variables
  from tensorflow.python.platform import test
  from tensorflow.python.training import training
label_desc: Use image node_id 8 for calling the MemoryOptimizerRecomputeTest obj's underlying member method code with example usage: obj._annotated_graph() and returns: graph,  init_op,  train_op