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: Check whether the input tensor is a DTensor.
  
  In Python, a DTensor has the same type as a `tf.Tensor`. This method will
  let you check and handle the tensor differently if a tf.Tensor is a DTensor.
  
  Args:
    tensor: an object to be checked.
  
  Returns:
    bool, True if the given tensor is a DTensor.
  
  Raises:
    RuntimeError: When not called eagerly.
docstr_tok: ["Check","whether","the","input","tensor","is","a","DTensor",".","In","Python",",","a","DTensor","has","the","same","type","as","a","`","tf.Tensor","`",".","This","method","will","let","you","check","and","handle","the","tensor","differently","if","a","tf.Tensor","is","a","DTensor",".","Args",":","tensor",":","an","object","to","be","checked",".","Returns",":","bool",",","True","if","the","given","tensor","is","a","DTensor",".","Raises",":","RuntimeError",":","When","not","called","eagerly","."]
code: def is_dtensor(self, tensor: Any) -> bool:
      """Check whether the input tensor is a DTensor.
  
      In Python, a DTensor has the same type as a `tf.Tensor`. This method will
      let you check and handle the tensor differently if a tf.Tensor is a DTensor.
  
      Args:
        tensor: an object to be checked.
  
      Returns:
        bool, True if the given tensor is a DTensor.
  
      Raises:
        RuntimeError: When not called eagerly.
      """
      if not context.executing_eagerly():
          raise RuntimeError("`is_dtensor` must be called eagerly.")
      if not tensor_util.is_tensor(tensor):
          return False
      if _pywrap_utils.IsVariable(tensor):
          tensor = tensor._handle  # pylint: disable=protected-access
      return _pywrap_dtensor_device.IsDTensor(
          context.context()._handle,  # pylint: disable=protected-access
          tensor,
          self._device_info,
      )
  
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 8 for calling the DTensorDevice obj's underlying member method code with example usage: obj.is_dtensor(tensor) and returns: _pywrap_dtensor_device, False