class_docstr: Creates mtf graph, mesh, and mesh implementation.
class_docstr_tok: ["Creates","mtf","graph",",","mesh",",","and","mesh","implementation","."]
docstr: Return the list of CPU and GPU (if any) devices in legacy name.
docstr_tok: ["Return","the","list","of","CPU","and","GPU","(","if","any",")","devices","in","legacy","name","."]
code: def _list_cpu_gpu_devices(self, sess):
      """Return the list of CPU and GPU (if any) devices in legacy name."""
  
      def _convert_to_legacy_name(n):
          n = re.sub("device:CPU", "cpu", n)
          n = re.sub("device:GPU", "gpu", n)
          return n
  
      def _sort_device_name(devices):
          parsed = []
          for d in devices:
              m = re.match("/job:(.*)/replica:(.*)/task:(.*)/.*", d)
              parsed.append(
                  (m.group(1), int(m.group(2)), int(m.group(3)), d)
              )
          return [_[3] for _ in sorted(parsed)]
  
      all_devices = sess.list_devices()
  
      cpus = []
      for d in all_devices:
          if d.device_type == "CPU":
              cpus += [_convert_to_legacy_name(d.name)]
      cpus = [
          n for n in _sort_device_name(cpus) if "coordinator" not in n
      ]
  
      gpus = []
      for d in all_devices:
          if d.device_type == "GPU":
              gpus += [_convert_to_legacy_name(d.name)]
      gpus = _sort_device_name(gpus)
  
      return cpus, gpus
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import re
  import mesh_tensorflow
  import numpy
  import six
  from six.moves import range
  from six.moves import zip
  import tensorflow.compat.v1
  from tensorflow.compat.v1 import estimator
  from mesh_tensorflow.experimental import input_reader
  from mesh_tensorflow.experimental import unet
  from tensorflow.contrib import summary
  from tensorflow.contrib import tpu
  from tensorflow.contrib.tpu.python.tpu import device_assignment
  from tensorflow.python.framework import ops
  from tensorflow.python.ops import control_flow_ops
  from tensorflow.python.platform import flags
  from tensorflow.python.tpu.ops import tpu_ops
label_desc: Use image node_id 8 for calling the MeshContext obj's underlying member method code with example usage: obj._list_cpu_gpu_devices(sess) and returns: cpus,  gpus, n, unknown