class_docstr: A distribution strategy for synchronous training on multiple workers.
  
  This strategy implements synchronous distributed training across multiple
  workers, each with potentially multiple GPUs. Similar to
  `tf.distribute.MirroredStrategy`, it replicates all variables and computations
  to each local device. The difference is that it uses a distributed collective
  implementation (e.g. all-reduce), so that multiple workers can work together.
class_docstr_tok: ["A","distribution","strategy","for","synchronous","training","on","multiple","workers",".","This","strategy","implements","synchronous","distributed","training","across","multiple","workers",",","each","with","potentially","multiple","GPUs",".","Similar","to","`","tf.distribute.MirroredStrategy","`",",","it","replicates","all","variables","and","computations","to","each","local","device",".","The","difference","is","that","it","uses","a","distributed","collective","implementation","(","e.g",".","all-reduce",")",",","so","that","multiple","workers","can","work","together","."]
docstr: Creates the strategy.
  
  Args:
    cluster_resolver: optional
      `tf.distribute.cluster_resolver.ClusterResolver`. In case neither `mesh`
      nor `cluster_resolver` are provided,
      `tf.distribute.cluster_resolver.TFConfigClusterResolver` is used.
    communication_options: currently ignore.
    mesh: optional Dtensor global mesh for the computation. Note that either
      `mesh` or the `cluster_resolver` should be provided. and not both.
docstr_tok: ["Creates","the","strategy",".","Args",":","cluster_resolver",":","optional","`","tf.distribute.cluster_resolver.ClusterResolver","`",".","In","case","neither","`","mesh","`","nor","`","cluster_resolver","`","are","provided",",","`","tf.distribute.cluster_resolver.TFConfigClusterResolver","`","is","used",".","communication_options",":","currently","ignore",".","mesh",":","optional","Dtensor","global","mesh","for","the","computation",".","Note","that","either","`","mesh","`","or","the","`","cluster_resolver","`","should","be","provided",".","and","not","both","."]
code: def __init__(
      self,
      cluster_resolver=None,
      communication_options=None,
      *,
      mesh=None,
  ):
      """Creates the strategy.
  
      Args:
        cluster_resolver: optional
          `tf.distribute.cluster_resolver.ClusterResolver`. In case neither `mesh`
          nor `cluster_resolver` are provided,
          `tf.distribute.cluster_resolver.TFConfigClusterResolver` is used.
        communication_options: currently ignore.
        mesh: optional Dtensor global mesh for the computation. Note that either
          `mesh` or the `cluster_resolver` should be provided. and not both.
      """
      self._validate_init_args(mesh, cluster_resolver)
      if not mesh:
          if not cluster_resolver:
              # Use the TFConfigClusterResolver as default
              cluster_resolver = (
                  tfconfig_cluster_resolver.TFConfigClusterResolver()
              )
          dtensor_env_var = (
              _parse_dtensor_env_var_from_cluster_resolver(
                  cluster_resolver
              )
          )
          _config_dtensor_env_var(dtensor_env_var)
          mesh = _build_distributed_mesh(
              dtensor_util.DEFAULT_BATCH_MESH_DIM_NAME
          )
      extended = dtensor_strategy_extended.DTensorStrategyExtended(
          container_strategy=self, mesh=mesh
      )
      super().__init__(extended)
      self._mesh = mesh
      self._cluster_resolver = cluster_resolver
  
file_path: tensorflow/tensorflow/python/distribute/experimental/multi_worker_mirrored_strategy.py
imports: import os
  from tensorflow.dtensor.python import config
  from tensorflow.dtensor.python import mesh_util
  from tensorflow.python.distribute import distribute_lib
  from tensorflow.python.distribute import multi_worker_util
  from tensorflow.python.distribute.cluster_resolver import tfconfig_cluster_resolver
  from tensorflow.python.distribute.experimental import dtensor_strategy_extended
  from tensorflow.python.distribute.experimental import dtensor_util
label_desc: Use image node_id 1 to create a new MultiWorkerMirroredStrategy object from inherited base classes: distribute_lib with example: obj = MultiWorkerMirroredStrategy(cluster_resolver, communication_options)