class_docstr: Wraps a custom device which attempts to propagate tensor layouts.
class_docstr_tok: ["Wraps","a","custom","device","which","attempts","to","propagate","tensor","layouts","."]
docstr: Create a new DTensorDevice which executes ops on `underlying_device`.
  
  Args:
    meshes: A list of `Mesh` objects indicating groups of devices to execute
      on. These may also be registered lazily.
    is_async: Indicates whether DTensor operations on this client will return
      immediately (with "non-ready" handles) or block until executed. This is
      on by default and is exposed as an option for ease of debugging.
    in_flight_nodes_limit: Indicates the limit of in-flight nodes before
      enqueueing of async operations to DTensorDevice is blocked. This limit
      is per mesh. 0 for no limits from DTensor. Default is 8.
docstr_tok: ["Create","a","new","DTensorDevice","which","executes","ops","on","`","underlying_device","`",".","Args",":","meshes",":","A","list","of","`","Mesh","`","objects","indicating","groups","of","devices","to","execute","on",".","These","may","also","be","registered","lazily",".","is_async",":","Indicates","whether","DTensor","operations","on","this","client","will","return","immediately","(","with","``","non-ready","''","handles",")","or","block","until","executed",".","This","is","on","by","default","and","is","exposed","as","an","option","for","ease","of","debugging",".","in_flight_nodes_limit",":","Indicates","the","limit","of","in-flight","nodes","before","enqueueing","of","async","operations","to","DTensorDevice","is","blocked",".","This","limit","is","per","mesh",".","0","for","no","limits","from","DTensor",".","Default","is","8","."]
code: def __init__(
      self,
      meshes: List[layout_lib.Mesh],
      is_async=True,
      in_flight_nodes_limit=8,
  ):
      """Create a new DTensorDevice which executes ops on `underlying_device`.
  
      Args:
        meshes: A list of `Mesh` objects indicating groups of devices to execute
          on. These may also be registered lazily.
        is_async: Indicates whether DTensor operations on this client will return
          immediately (with "non-ready" handles) or block until executed. This is
          on by default and is exposed as an option for ease of debugging.
        in_flight_nodes_limit: Indicates the limit of in-flight nodes before
          enqueueing of async operations to DTensorDevice is blocked. This limit
          is per mesh. 0 for no limits from DTensor. Default is 8.
      """
      if any(not isinstance(mesh, layout_lib.Mesh) for mesh in meshes):
          raise TypeError(
              "Expected a flat list of Mesh objects, got {}".format(
                  meshes
              )
          )
      global _next_device_number
      ctx = context.context()
      with _next_device_number_lock:
          self.name = "{}/device:CUSTOM:{}".format(
              ctx.host_address_space(), _next_device_number
          )
          _next_device_number += 1
      device, device_info = _pywrap_dtensor_device.Allocate(
          self.name, is_async, in_flight_nodes_limit
      )
      context.register_custom_device(device, self.name, device_info)
  
      self._device_info = device_info
      self._current_output_layout = None
      self._current_default_mesh = None
      self._meshes = set()
      self._mesh_lock = threading.Lock()
      for mesh in meshes:
          self._register_mesh(mesh)
  
imports: import contextlib
  import logging
  import threading
  from typing import Any, List, Sequence, Set
  import numpy
  from tensorflow.core.framework import attr_value_pb2
  from tensorflow.dtensor.python import config
  from tensorflow.dtensor.python import layout
  from tensorflow.python import _pywrap_dtensor_device
  from tensorflow.python.eager import context
  from tensorflow.python.eager import core
  from tensorflow.python.framework import device
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import sparse_tensor
  from tensorflow.python.framework import tensor_util
  from tensorflow.python.util import _pywrap_utils
label_desc: Use image node_id 1 to create a new DTensorDevice object from inherited base classes: object with example: obj = DTensorDevice(meshes, is_async, in_flight_nodes_limit)