class_docstr: An utility class that maps between pnum to devices.
class_docstr_tok: ["An","utility","class","that","maps","between","pnum","to","devices","."]
docstr: Init tpu and host devices in logical order.
docstr_tok: ["Init","tpu","and","host","devices","in","logical","order","."]
code: def __init__(self, simd_mesh_impl):
      """Init tpu and host devices in logical order."""
      self._num_cores = simd_mesh_impl.device_assignment.num_replicas
  
      self._ordered_ordinals = []
      self._ordered_tpus = []
      self._ordered_hosts = []
      self._ordered_host_ids = []
      self._host_id_to_its_pnums = collections.defaultdict(list)
      d_assignment = simd_mesh_impl.device_assignment
  
      for pnum in range(self.num_cores):
          physical_pnum = simd_mesh_impl.l2p(pnum)
  
          # For MTF, there's always 1 core per replica. So logical_core=0.
          self._ordered_ordinals.append(
              d_assignment.tpu_ordinal(
                  replica=physical_pnum, logical_core=0
              )
          )
          tpu_device = d_assignment.tpu_device(replica=physical_pnum)
          host_device = d_assignment.host_device(replica=physical_pnum)
          host_id = _host_device_to_id(host_device)
          self._ordered_tpus.append(tpu_device)
          self._ordered_hosts.append(host_device)
          self._ordered_host_ids.append(host_id)
          self._host_id_to_its_pnums[host_id].append(pnum)
  
      self._num_hosts = len(set(self._ordered_hosts))
      self._num_cores_per_host = self.num_cores // self._num_hosts
      assert (
          self.num_cores == self._num_hosts * self._num_cores_per_host
      )
  
      tf.logging.info(
          "Process Devices "
          "ordered_ordinals: {}, "
          "ordered_tpus: {}, "
          "ordered_hosts: {}, "
          "host_id_to_its_pnums: {}.".format(
              self.ordered_ordinals,
              self.ordered_tpus,
              self.ordered_hosts,
              self.host_id_to_its_pnums,
          )
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  import threading
  import time
  import numpy
  from six.moves import range
  from six.moves import zip
  import tensorflow.compat.v1
  from tensorflow.python.framework import ops
  from tensorflow.python.tpu import tpu_feed
label_desc: Use image node_id 1 to create a new ProcessDevices object from inherited base classes: object with example: obj = ProcessDevices(simd_mesh_impl)