docstr: Tests that replacing servers works correctly.
  
  We create two servers, t1 and t2. We first replace t2, then we replace t1.
  
  Among other things, this ensures that both already existing, and
  restarted workers have the context view IDs correctly updated.
docstr_tok: ["Tests","that","replacing","servers","works","correctly",".","We","create","two","servers",",","t1","and","t2",".","We","first","replace","t2",",","then","we","replace","t1",".","Among","other","things",",","this","ensures","that","both","already","existing",",","and","restarted","workers","have","the","context","view","IDs","correctly","updated","."]
code: def testDistributedFunctionBothServersReplaced(self):
      """Tests that replacing servers works correctly.
  
      We create two servers, t1 and t2. We first replace t2, then we replace t1.
  
      Among other things, this ensures that both already existing, and
      restarted workers have the context view IDs correctly updated.
      """
      with ops.device(self.device_local):
          x1 = array_ops.ones([2, 2])
  
      @def_function.function
      def worker_fn(i):
          with ops.device(self.device_t1):
              mul = math_ops.matmul(i, i)
          with ops.device(self.device_t2):
              add = mul + i
          return add - i
  
      # Forces function tracing and registration
      worker_fn.get_concrete_function(x1)
  
      # Replace task2
      context.update_server_def(server_def=self.server_def_s1_s3)
      for device in (self.device_t1, self.device_t2):
          with ops.device(device):
              y = worker_fn(x1)
          np.testing.assert_array_equal([[2, 2], [2, 2]], y.numpy())
  
      # Then replace task1
      context.update_server_def(server_def=self.server_def_s4_s3)
      for device in (self.device_t1, self.device_t2):
          with ops.device(device):
              y = worker_fn(x1)
          np.testing.assert_array_equal([[2, 2], [2, 2]], y.numpy())
  
imports: import os
  import threading
  from absl.testing import parameterized
  import numpy
  from tensorflow.core.distributed_runtime.preemption import gen_check_preemption_op
  from tensorflow.core.protobuf import cluster_pb2
  from tensorflow.core.protobuf import tensorflow_server_pb2
  from tensorflow.python import pywrap_tfe
  from tensorflow.python.eager import context
  from tensorflow.python.eager import def_function
  from tensorflow.python.eager import executor
  from tensorflow.python.framework import errors
  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 math_ops
  from tensorflow.python.ops import variables
  from tensorflow.python.platform import test
  from tensorflow.python.training import coordinator
  from tensorflow.python.training import server_lib
label_desc: Use image node_id 18 for calling the DynamicClusterTest obj's underlying member method code with example usage: obj.testDistributedFunctionBothServersReplaced() and returns: unknown