code: def testClearDevices(self):
      graph1 = ops.Graph()
      with graph1.as_default():
          with ops.device("/device:CPU:0"):
              a = variables.Variable(
                  constant_op.constant(1.0, shape=[2, 2]), name="a"
              )
          with ops.device("/job:ps/replica:0/task:0/device:GPU:0"):
              b = variables.Variable(
                  constant_op.constant(2.0, shape=[2, 2]), name="b"
              )
          with ops.device("/job:localhost/replica:0/task:0/cpu:0"):
              math_ops.matmul(a, b, name="matmul")
  
      self.assertEqual(
          "/device:CPU:0", str(graph1.as_graph_element("a").device)
      )
      self.assertEqual(
          "/job:ps/replica:0/task:0/device:GPU:0",
          str(graph1.as_graph_element("b").device),
      )
      self.assertEqual(
          "/job:localhost/replica:0/task:0/device:CPU:0",
          str(graph1.as_graph_element("matmul").device),
      )
  
      # Verifies that devices are cleared on export.
      orig_meta_graph, _ = meta_graph.export_scoped_meta_graph(
          graph=graph1, clear_devices=True
      )
  
      graph2 = ops.Graph()
      with graph2.as_default():
          meta_graph.import_scoped_meta_graph(
              orig_meta_graph, clear_devices=False
          )
  
      self.assertEqual("", str(graph2.as_graph_element("a").device))
      self.assertEqual("", str(graph2.as_graph_element("b").device))
      self.assertEqual(
          "", str(graph2.as_graph_element("matmul").device)
      )
  
      # Verifies that devices are cleared on export when passing in graph_def.
      orig_meta_graph, _ = meta_graph.export_scoped_meta_graph(
          graph_def=graph1.as_graph_def(), clear_devices=True
      )
  
      graph2 = ops.Graph()
      with graph2.as_default():
          meta_graph.import_scoped_meta_graph(
              orig_meta_graph, clear_devices=False
          )
  
      self.assertEqual("", str(graph2.as_graph_element("a").device))
      self.assertEqual("", str(graph2.as_graph_element("b").device))
      self.assertEqual(
          "", str(graph2.as_graph_element("matmul").device)
      )
  
      # Verifies that devices are cleared on import.
      orig_meta_graph, _ = meta_graph.export_scoped_meta_graph(
          graph=graph1, clear_devices=False
      )
  
      graph2 = ops.Graph()
      with graph2.as_default():
          meta_graph.import_scoped_meta_graph(
              orig_meta_graph, clear_devices=True
          )
  
      self.assertEqual("", str(graph2.as_graph_element("a").device))
      self.assertEqual("", str(graph2.as_graph_element("b").device))
      self.assertEqual(
          "", str(graph2.as_graph_element("matmul").device)
      )
  
imports: import math
  import os.path
  import random
  import shutil
  from tensorflow.core.framework import graph_pb2
  from tensorflow.core.protobuf import meta_graph_pb2
  from tensorflow.python.client import session
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import function
  from tensorflow.python.framework import meta_graph
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import cond
  from tensorflow.python.ops import data_flow_ops
  from tensorflow.python.ops import gradients_impl
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import metrics
  from tensorflow.python.ops import nn_ops
  from tensorflow.python.ops import partitioned_variables
  from tensorflow.python.ops import random_ops
  from tensorflow.python.ops import resource_variable_ops
  from tensorflow.python.ops import variable_scope
  from tensorflow.python.ops import variables
  from tensorflow.python.ops import while_loop
  from tensorflow.python.platform import gfile
  from tensorflow.python.platform import test
  from tensorflow.python.training import queue_runner_impl
label_desc: Use image node_id 17 for calling the ScopedMetaGraphTest obj's underlying member method code with example usage: obj.testClearDevices() without return types