code: def testMap_Scoped(self):
      with self.cached_session() as sess:
  
          def double_scoped(x):
              """2x with a dummy 2 that is scoped."""
              with variable_scope.variable_scope("body"):
                  # Dummy variable, just to check that scoping works as intended.
                  two = variable_scope.get_variable(
                      "two",
                      [],
                      dtype=dtypes.int32,
                      initializer=init_ops.constant_initializer(2),
                  )
                  return math_ops.multiply(x, two)
  
          with variable_scope.variable_scope("root") as varscope:
              elems = constant_op.constant(
                  [1, 2, 3, 4, 5, 6], name="data"
              )
              doubles = np.array([2 * x for x in [1, 2, 3, 4, 5, 6]])
  
              r = map_fn.map_fn(double_scoped, elems)
              # Check that we have the one variable we asked for here.
              self.assertEqual(len(variables.trainable_variables()), 1)
              self.assertEqual(
                  variables.trainable_variables()[0].name,
                  "root/body/two:0",
              )
              sess.run([variables.global_variables_initializer()])
              self.assertAllEqual(doubles, self.evaluate(r))
  
              # Now let's reuse our single variable.
              varscope.reuse_variables()
              r = map_fn.map_fn(double_scoped, elems)
              self.assertEqual(len(variables.trainable_variables()), 1)
              self.assertAllEqual(doubles, self.evaluate(r))
  
imports: import numpy
  from tensorflow.python.eager import context
  from tensorflow.python.eager import def_function
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import sparse_tensor
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import gradients_impl
  from tensorflow.python.ops import init_ops
  from tensorflow.python.ops import map_fn
  from tensorflow.python.ops import math_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.ragged import ragged_factory_ops
  from tensorflow.python.ops.ragged import ragged_tensor
  import tensorflow.python.ops.tensor_array_grad
  from tensorflow.python.platform import test
label_desc: Use image node_id 7 for calling the MapFnTest obj's underlying member method code with example usage: obj.testMap_Scoped() and returns: math_ops