class_docstr: Used to perform in-graph replication on a computational graph.
  
  That is, Replicator is used to create _n_ replicas of a `tf.Graph`,
  with all replicas being stored in a new `tf.Graph` and delineated
  with name scopes.
  
  This also handles ControlFlowContexts, updating variable and gradient
  information, etc.
class_docstr_tok: ["Used","to","perform","in-graph","replication","on","a","computational","graph",".","That","is",",","Replicator","is","used","to","create","_n_","replicas","of","a","`","tf.Graph","`",",","with","all","replicas","being","stored","in","a","new","`","tf.Graph","`","and","delineated","with","name","scopes",".","This","also","handles","ControlFlowContexts",",","updating","variable","and","gradient","information",",","etc","."]
docstr: A device placer function that places CPU-only ops on CPU instead of destination devices.
docstr_tok: ["A","device","placer","function","that","places","CPU-only","ops","on","CPU","instead","of","destination","devices","."]
code: def _replica_device_placer(self, replica_id):
      """A device placer function that places CPU-only ops on CPU instead of destination devices."""
      # strategy device `new_device` merges onto the original `old_device`
      replica_device = self._local_canonical_replica_devices[replica_id]
  
      def placer(op):
          if all(
              [
                  "CPU" in kernel_def.device_type
                  for kernel_def in kernels.get_registered_kernels_for_op(
                      op.type
                  ).kernel
              ]
          ):
              # It assumes an op has a CPU kernel by default.
              new_device = DeviceSpecV2.from_string(
                  self._local_worker_device
              ).replace(device_type="CPU", device_index=0)
          else:
              new_device = DeviceSpecV2.from_string(replica_device)
          return new_device
  
      return placer
  
file_path: autodist/autodist/kernel/replicator.py
imports: from tensorflow.python import ops, import_graph_def
  from tensorflow.python.framework import device_spec, kernels
  from tensorflow.python.framework.device_spec import DeviceSpecV2
  from tensorflow.python.ops.control_flow_ops import WhileContext
  from tensorflow.python.ops.control_flow_util import GetWhileContext
  from tensorflow.python.ops.resource_variable_ops import _from_proto_fn
  from autodist.graph_item import GraphItem
  from autodist.kernel.common.utils import replica_prefix
  from autodist.kernel.kernel import Kernel
  from autodist.checkpoint.saver import Saver
  from autodist.utils import logging
label_desc: Use image node_id 4 for calling the Replicator obj's underlying member method code with example usage: obj._replica_device_placer(replica_id) and returns: placer, new_device