code: def test_swap_SharedVariable(self):
      i = T.iscalar()
      x_list = theano.shared(
          value=np.random.rand(10).astype(config.floatX)
      )
  
      x = T.scalar("x")
      # SharedVariable for tests, one of them has update
      y = theano.shared(value=1, name="y")
      z = theano.shared(value=2, name="z")
      m = theano.shared(value=0, name="m")
  
      # SharedVariable to replace
      y_rpl = theano.shared(value=3, name="y_rpl")
      z_rpl = theano.shared(value=4, name="z_rpl")
      swap = {y: y_rpl, z: z_rpl}
      map_SV = {"y_rpl": y_rpl, "z_rpl": z_rpl}
  
      out = x + y + z + m
  
      # Test for different linkers
      # for mode in ["FAST_RUN","FAST_COMPILE"]:
      second_time = False
      for mode in ["FAST_RUN", "FAST_COMPILE"]:
          ori = theano.function(
              [i],
              [out],
              mode=mode,
              updates=[(z, z + 1), (m, m + 2)],
              givens={x: x_list[i]},
          )
          cpy = ori.copy(swap=swap)
  
          # run fuction several time
          ori(1), cpy(1), cpy(2)
  
          # assert same SharedVariable are update in different function
          if not second_time:
              # m should be updated 3 times
              assert m.get_value() == 6
              # z should be updated once
              assert z.get_value() == 3
              # z_rpl should be updated twice
              assert z_rpl.get_value() == 6
              # y and y_rpl should not be updated
              assert y_rpl.get_value() == 3
              assert y.get_value() == 1
          elif second_time:
              # doule update for sharedvariable
              assert m.get_value() == 12
              assert z.get_value() == 4
              assert z_rpl.get_value() == 8
              assert y_rpl.get_value() == 3
  
          # test cpy function:
          # 2. SharedVariable is updatable -> values did update(z == 5)
          # 1. sharedvariable is swap ->  Rpl sharedvariables share storage
          names = map_SV.keys()
          for key in cpy.fn.storage_map:
              if key.name in names:
                  assert (
                      map_SV[key.name].container.storage[0]
                      == cpy.fn.storage_map[key][0]
                  )
  
          second_time = True
  
imports: from __future__ import absolute_import, print_function, division
  import copy
  import six.moves.cPickle
  import numpy
  import unittest
  import time
  from theano import config, gof
  from six import iteritems
  from theano.compile.io import In, Out
  from theano.compile import function
  from theano.compile import UnusedInputError
  from theano.gof import MissingInputError
  from theano.compat import exc_message
  from theano.tests.unittest_tools import SkipTest
  from theano import tensor
  from theano import tensor
  import theano
label_desc: Use image node_id 17 for calling the T_function obj's underlying member method code with example usage: obj.test_swap_SharedVariable() without return types