code: def allconcat_ring(xs, devices, concat_axis):
      """Concatenate all Tensors everywhere.
  
      Performance-optimized for a ring of devices.
  
      Args:
        xs: a list of n tf.Tensors
        devices: a list of n strings
        concat_axis: an integer
  
      Returns:
        a list of n Tensors
      """
      n = len(xs)
      if n == 1:
          return xs
      # [target, source]
      parts = [
          [
              xs[target] if target == source else None
              for source in xrange(n)
          ]
          for target in xrange(n)
      ]
      for distance in xrange(1, n // 2 + 1):
          for target in xrange(n):
              source = (target + distance) % n
              if parts[target][source] is None:
                  with tf.device(devices[target]):
                      parts[target][source] = tf.identity(
                          parts[(target + 1) % n][source]
                      )
              source = (target - distance) % n
              if parts[target][source] is None:
                  with tf.device(devices[target]):
                      parts[target][source] = tf.identity(
                          parts[(target - 1) % n][source]
                      )
      return mtf.parallel(
          devices, tf.concat, parts, axis=[concat_axis] * n
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import functools
  import os
  import random
  from mesh_tensorflow import ops_with_redefined_builtins
  from six.moves import xrange
  import tensorflow.compat.v1
label_desc: Use image node_id 3 for calling a global function with example usage: allconcat_ring(xs, devices, concat_axis) and returns: mtf, xs