class_docstr: Helper class to assign variables on the least loaded ps-device.
  
  Usage:
  
      .. code-block:: python
  
          with tf.device(LeastLoadedDeviceSetter(...)):
              ...
code: def __call__(self, op):
      # from tensorflow.python.training.device_util import canonicalize
      # from tensorflow.python.distribute.device_util import canonicalize
      def canonicalize(name):  # tensorflow/tensorflow#11484
          return tfv1.DeviceSpec.from_string(name).to_string()
  
      if op.device:
          return op.device
      if op.type not in ["Variable", "VariableV2"]:
          return canonicalize(self.worker_device)
  
      device_name = self.place_with_balance(op)
      return canonicalize(device_name)
  
imports: import operator
  from contextlib import contextmanager
  import tensorflow
  import threading
  from ..compat import tfv1
  from ..tfutils.common import get_tf_version_tuple
  from ..tfutils.scope_utils import cached_name_scope, under_name_scope
  from ..tfutils.varreplace import custom_getter_scope
  from ..utils import logger
  from ..utils.argtools import call_only_once
label_desc: Use image node_id 2 for calling the LeastLoadedDeviceSetter obj's underlying member method code with example usage: obj.__call__(op) and returns: canonicalize, tfv1, op, canonicalize