code: def relayout(
      tensor: tensor_lib.Tensor,
      layout: layout_lib.Layout,
      name: Optional[str] = None,
  ) -> tensor_lib.Tensor:
      """Changes the layout of `tensor`.
  
      Changes the layout of `tensor` to `layout`. This is used to fine-tune the
      behavior of ops following/connected to `tensor`, such as choosing one SPMD
      expansion pattern over another. This works by forward propagating `layout`
      to connected TensorFlow computation graphs during layout propagation.
  
      Currently, only converting layouts from replicated to sharded or sharded to
      replicated per mesh dimension is supported. That is, "x, y" -> "unsharded, y"
      is supported, while "x, y" -> "z, y" is not supported.
  
      We also support a special "match" sharding spec, which instructs the relayout
      to act as an identity operation with respect to any sharding on these
      mesh dimensions.
  
      Relayout is internally lowered to a set of Split and/or AllToAll ops. When
      tensor layouts are converted from replicated to sharded, the cost is
      comparatively low because we only insert Split ops and no cross-device
      communication is needed. However, when tensor layouts are converted from
      sharded to replicated, cross-device communication may occur, causing potential
      performance impact.
  
      Args:
        tensor: A DTensor to specify a new layout for.
        layout: A Layout object specifying a new sharding spec.
        name: name of the Op.
  
      Returns:
        A DTensor output from the Relayout op.
      """
      layout_str = layout.to_string()
      with default_mesh(layout.mesh):
          return gen_dtensor_ops.relayout(tensor, layout_str, name=name)
  
imports: import contextlib
  import threading
  from typing import Any, Callable, Optional, Sequence
  from tensorflow.dtensor.python import dtensor_device
  from tensorflow.dtensor.python import gen_dtensor_ops
  from tensorflow.dtensor.python import layout
  from tensorflow.python.eager import context
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor
  from tensorflow.python.util import deprecation
  from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 12 for calling a global function with example usage: relayout(tensor, layout, name) and returns: gen_dtensor_ops