(num_gpus, all_reduce_alg='nccl')
Return a DistributionStrategy for running the model.

  Args:
    num_gpus: Number of GPUs to run this model.
    all_reduce_alg: Specify which algorithm to use when performing all-reduce.
      See tf.distribute.NcclAllReduce for available algorithms.
      If None, Strategy will using nccl as default.

  Returns:
    tf.distribute.Strategy object.
Return a DistributionStrategy for running the model.
Return a DistributionStrategy for running the model .
def get_distribution_strategy(num_gpus, all_reduce_alg='nccl'):
  """Return a DistributionStrategy for running the model.

  Args:
    num_gpus: Number of GPUs to run this model.
    all_reduce_alg: Specify which algorithm to use when performing all-reduce.
      See tf.distribute.NcclAllReduce for available algorithms.
      If None, Strategy will using nccl as default.

  Returns:
    tf.distribute.Strategy object.
  """
  if num_gpus == 0:  #pylint: disable=no-else-return
    return tf.distribute.OneDeviceStrategy("device:CPU:0")
  elif num_gpus == 1:
    return tf.distribute.OneDeviceStrategy("device:GPU:0")
  else:
    return tf.distribute.MirroredStrategy(devices=None, cross_device_ops=None)
def get_distribution_strategy ( num_gpus , all_reduce_alg = 'nccl' ) : if num_gpus == 0 : #pylint: disable=no-else-return return tf . distribute . OneDeviceStrategy ( "device:CPU:0" ) elif num_gpus == 1 : return tf . distribute . OneDeviceStrategy ( "device:GPU:0" ) else : return tf . distribute . MirroredStrategy ( devices = None , cross_device_ops = None )