# Path: mesh_tensorflow/ops_with_redefined_builtins.py



import functools
import os
import random
import tensorflow.compat.v1 as tf
from mesh_tensorflow import ops_with_redefined_builtins as mtf
from six.moves import xrange  # pylint: disable=redefined-builtin
          self._copy_master_to_slices = self.assign_to_slices(
              mtf.assign_slice,
              mesh_impl.make_slices(variable.get_master(), shape))
        self._copy_slices_to_master = variable.assign_to_master(
            mesh_impl.combine_slices(slices_with_master_dtype, shape))

    @property
    def slice_is_master(self):
      """Should we avoid creating a slice variable and just use the master."""
      if self._mesh_impl.size != 1:
        return False
      if self._variable.master_dtype != self._variable.slice_dtype:
        return False
      if isinstance(self._variable, mtf.StackedVariable):
        return False
      master_device = self._variable.master_device
      slice_device = self._mesh_impl.devices[0]
      return slice_device == master_device or not slice_device

    def assign_to_slices(self, assign_fn, values):
      """Assign to the slice variables.

      Args:
        assign_fn: a function from
          (mtf.Variable, tf.Variable, tf.Tensor) -> tf.Operation
        values: a list of tf.Tensor

      Returns:
        a tf.operation
      """

# Path: mesh_tensorflow/ops_with_redefined_builtins.py



# Path: mesh_tensorflow/placement_mesh_impl.py
import functools
import os
import random
import tensorflow.compat.v1 as tf
from mesh_tensorflow import ops_with_redefined_builtins as mtf
from six.moves import xrange  # pylint: disable=redefined-builtin

          self._copy_master_to_slices = self.assign_to_slices(
              mtf.assign_slice,
              mesh_impl.make_slices(variable.get_master(), shape))
        self._copy_slices_to_master = variable.assign_to_master(
            mesh_impl.combine_slices(slices_with_master_dtype, shape))

    @property
    def slice_is_master(self):
      """Should we avoid creating a slice variable and just use the master."""
      if self._mesh_impl.size != 1:
        return False
      if self._variable.master_dtype != self._variable.slice_dtype:
        return False
      if isinstance(self._variable, mtf.StackedVariable):
        return False
      master_device = self._variable.master_device
      slice_device = self._mesh_impl.devices[0]
      return slice_device == master_device or not slice_device

    def assign_to_slices(self, assign_fn, values):
      """Assign to the slice variables.

      Args:
        assign_fn: a function from
          (mtf.Variable, tf.Variable, tf.Tensor) -> tf.Operation
        values: a list of tf.Tensor

      Returns:
        a tf.operation
      """

      return tf.group(mtf.parallel(