code: def test_sync_weights_with_batch_norm(self):
      model = TestModel3()
      target_model = deepcopy(model)
  
      program1 = fluid.Program()
      program2 = fluid.Program()
      with fluid.program_guard(program1):
          obs = layers.data(
              name="obs", shape=[32, 128, 128], dtype="float32"
          )
          model_output = model.predict(obs)
          loss = layers.reduce_mean(model_output)
          optimizer = fluid.optimizer.AdamOptimizer(1e-3)
          optimizer.minimize(loss)
  
      with fluid.program_guard(program2):
          obs = layers.data(
              name="obs", shape=[32, 128, 128], dtype="float32"
          )
          model_output = model.predict(obs)
          target_model_output = target_model.predict(obs)
      self.executor.run(fluid.default_startup_program())
  
      N = 10
      random_obs = np.random.random(size=(N, 32, 128, 128)).astype(
          "float32"
      )
      for i in range(N):
          x = np.expand_dims(random_obs[i], axis=0)
          outputs = self.executor.run(
              program2,
              feed={"obs": x},
              fetch_list=[model_output, target_model_output],
          )
          self.assertNotEqual(
              np.sum(outputs[0].flatten()), np.sum(outputs[1].flatten())
          )
  
      # run optimizing to make parameters of batch_norm between model and target_model are different
      N = 100
      random_obs = np.random.random(size=(N, 32, 128, 128)).astype(
          "float32"
      )
      for i in range(N):
          x = np.expand_dims(random_obs[i], axis=0)
          self.executor.run(program1, feed={"obs": x})
  
      model.sync_weights_to(target_model)
  
      random_obs = np.random.random(size=(N, 32, 128, 128)).astype(
          "float32"
      )
      for i in range(N):
          x = np.expand_dims(random_obs[i], axis=0)
          outputs = self.executor.run(
              program2,
              feed={"obs": x},
              fetch_list=[model_output, target_model_output],
          )
          self.assertEqual(
              np.sum(outputs[0].flatten()), np.sum(outputs[1].flatten())
          )
  
imports: import numpy
  import paddle.fluid
  import parl
  import unittest
  from copy import deepcopy
  from paddle.fluid import ParamAttr
  from parl import layers
  from parl.utils import get_gpu_count
  from parl.core.fluid.plutils import fetch_value
label_desc: Use image node_id 14 for calling the ModelBaseTest obj's underlying member method code with example usage: obj.test_sync_weights_with_batch_norm() without return types