def one_step(self, current_state, previous_kernel_results):
<EOL>with tf.compat.v1.name_scope(<EOL>name=mcmc_util.make_name(self.name, '<STR_LIT>', '<STR_LIT>'),<EOL>values=[current_state, previous_kernel_results]):<EOL><INDENT>sampled_replica_states, sampled_replica_results = zip(*[<EOL>rk.one_step(previous_kernel_results.replica_states[i],<EOL>previous_kernel_results.replica_results[i])<EOL>for i, rk in enumerate(self.replica_kernels)<EOL>])<EOL>sampled_replica_states = list(sampled_replica_states)<EOL>sampled_replica_results = list(sampled_replica_results)<EOL>states_are_lists = mcmc_util.is_list_like(sampled_replica_states[<NUM_LIT:0>])<EOL>if not states_are_lists:<EOL><INDENT>sampled_replica_states = [[s] for s in sampled_replica_states]<EOL><DEDENT>num_state_parts = len(sampled_replica_states[<NUM_LIT:0>])<EOL>dtype = sampled_replica_states[<NUM_LIT:0>][<NUM_LIT:0>].dtype<EOL>old_states = [<EOL>tf.TensorArray(<EOL>dtype,<EOL>size=self.num_replica,<EOL>dynamic_size=False,<EOL>clear_after_read=False,<EOL>tensor_array_name='<STR_LIT>',<EOL>element_shape=sampled_replica_states[<NUM_LIT:0>][k].shape)<EOL>for k in range(num_state_parts)<EOL>]<EOL>for k in range(num_state_parts):<EOL><INDENT>for i in range(self.num_replica):<EOL><INDENT>old_states[k] = old_states[k].write(i, sampled_replica_states[i][k])<EOL><DEDENT><DEDENT>exchange_proposed = self.exchange_proposed_fn(<EOL>self.num_replica, seed=self._seed_stream())<EOL>exchange_proposed_n = tf.shape(input=exchange_proposed)[<NUM_LIT:0>]<EOL>exchanged_states = self._get_exchanged_states(<EOL>old_states, exchange_proposed, exchange_proposed_n,<EOL>sampled_replica_states, sampled_replica_results)<EOL>no_exchange_proposed, _ = tf.compat.v1.setdiff1d(<EOL>tf.range(self.num_replica), tf.reshape(exchange_proposed, [-<NUM_LIT:1>]))<EOL>exchanged_states = self._insert_old_states_where_no_exchange_was_proposed(<EOL>no_exchange_proposed, old_states, exchanged_states)<EOL>next_replica_states = []<EOL>for i in range(self.num_replica):<EOL><INDENT>next_replica_states_i = []<EOL>for k in range(num_state_parts):<EOL><INDENT>next_replica_states_i.append(exchanged_states[k].read(i))<EOL><DEDENT>next_replica_states.append(next_replica_states_i)<EOL><DEDENT>if not states_are_lists:<EOL><INDENT>next_replica_states = [s[<NUM_LIT:0>] for s in next_replica_states]<EOL>sampled_replica_states = [s[<NUM_LIT:0>] for s in sampled_replica_states]<EOL><DEDENT>next_replica_results = [<EOL>rk.bootstrap_results(state)<EOL>for rk, state in zip(self.replica_kernels, next_replica_states)<EOL>]<EOL>next_state = next_replica_states[<NUM_LIT:0>]  <EOL>kernel_results = ReplicaExchangeMCKernelResults(<EOL>replica_states=next_replica_states,<EOL>replica_results=next_replica_results,<EOL>sampled_replica_states=sampled_replica_states,<EOL>sampled_replica_results=sampled_replica_results,<EOL>)<EOL>return next_state, kernel_results<EOL><DEDENT>
Takes one step of the TransitionKernel.

        Args:
          current_state: `Tensor` or Python `list` of `Tensor`s representing the
            current state(s) of the Markov chain(s).
          previous_kernel_results: A (possibly nested) `tuple`, `namedtuple` or
            `list` of `Tensor`s representing internal calculations made within the
            previous call to this function (or as returned by `bootstrap_results`).

        Returns:
          next_state: `Tensor` or Python `list` of `Tensor`s representing the
            next state(s) of the Markov chain(s).
          kernel_results: A (possibly nested) `tuple`, `namedtuple` or `list` of
            `Tensor`s representing internal calculations made within this function.
            This inculdes replica states.