code: def monkey_patch_default_variable_placement_strategy():
      """Monkey patches the default variable placement strategy.
  
      This strategy is used by tf.train.replica_device_setter. The new strategy
      allows workers to having different graphs from the chief.
  
      Yields:
        A context with the monkey-patched default variable placement strategy.
      """
  
      # Import here to avoid strict BUILD deps check.
      from tensorflow.python.training import (
          device_setter,
      )  # pylint: disable=g-direct-tensorflow-import,g-import-not-at-top
  
      old_round_robin_strategy = (
          device_setter._RoundRobinStrategy
      )  # pylint: disable=protected-access
      setattr(device_setter, "_RoundRobinStrategy", _OpNameHashStrategy)
      try:
          yield
      finally:
          setattr(
              device_setter,
              "_RoundRobinStrategy",
              old_round_robin_strategy,
          )
  
file_path: adanet/adanet/distributed/devices.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import contextlib
  import hashlib
label_desc: Use image node_id 1 for calling a global function with example usage: monkey_patch_default_variable_placement_strategy() without return types