parameters: (devices, session_config=None)
docstring: Find the best CrossDeviceOps locally given a `tf.compat.v1.ConfigProto`.
  
    Args:
      devices: a list of devices passed to `tf.distribute.Strategy`.
      session_config: a `tf.compat.v1.ConfigProto` or `None`. If `None`, it will
        make decision based on all local devices.
  
    Returns:
      A subclass of `CrossDeviceOps`.
docstring_summary: Find the best CrossDeviceOps locally given a `tf.compat.v1.ConfigProto`.
docstring_tokens: Find the best CrossDeviceOps locally given a tf . compat . v1 . ConfigProto .
function: def choose_the_best(devices, session_config=None):
    """Find the best CrossDeviceOps locally given a `tf.compat.v1.ConfigProto`.
  
    Args:
      devices: a list of devices passed to `tf.distribute.Strategy`.
      session_config: a `tf.compat.v1.ConfigProto` or `None`. If `None`, it will
        make decision based on all local devices.
  
    Returns:
      A subclass of `CrossDeviceOps`.
    """
    requested_devices = set([device_util.canonicalize(d) for d in devices])
    machine_devices = device_lib.list_local_devices(session_config=session_config)
    using_devices = set()
    for d in machine_devices:
      if device_util.canonicalize(d.name) in requested_devices:
        using_devices.add(d.name)
  
    if len(using_devices) != len(requested_devices):
      logging.warning(
          "Some requested devices in `tf.distribute.Strategy` are not visible "
          "to TensorFlow: %s", ",".join(list(requested_devices - using_devices)))
      return ReductionToOneDevice()
  
    if any("gpu" not in d.lower() for d in using_devices):
      logging.warning("There is non-GPU devices in `tf.distribute.Strategy`, not "
                      "using nccl allreduce.")
      return ReductionToOneDevice()
  
    if kernels.get_registered_kernels_for_op("NcclAllReduce"):
      return NcclAllReduce(num_packs=1)
    else:
      logging.warning("Nccl kernel is not found, not using nccl allreduce.")
      return ReductionToOneDevice()
function_tokens: def choose_the_best ( devices , session_config = None ) : requested_devices = set ( [ device_util . canonicalize ( d ) for d in devices ] ) machine_devices = device_lib . list_local_devices ( session_config = session_config ) using_devices = set ( ) for d in machine_devices : if device_util . canonicalize ( d . name ) in requested_devices : using_devices . add ( d . name ) if len ( using_devices ) != len ( requested_devices ) : logging . warning ( "Some requested devices in `tf.distribute.Strategy` are not visible " "to TensorFlow: %s" , "," . join ( list ( requested_devices - using_devices ) ) ) return ReductionToOneDevice ( ) if any ( "gpu" not in d . lower ( ) for d in using_devices ) : logging . warning ( "There is non-GPU devices in `tf.distribute.Strategy`, not " "using nccl allreduce." ) return ReductionToOneDevice ( ) if kernels . get_registered_kernels_for_op ( "NcclAllReduce" ) : return NcclAllReduce ( num_packs = 1 ) else : logging . warning ( "Nccl kernel is not found, not using nccl allreduce." ) return ReductionToOneDevice ( )