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: Fetches the layout of the DTensor.
  
  Args:
    dtensor: The DTensor whose layout is to be fetched.
  
  Returns:
    The `Layout` of this DTensor.
  
  Raises:
    RuntimeError: When not called eagerly.
docstr_tok: ["Fetches","the","layout","of","the","DTensor",".","Args",":","dtensor",":","The","DTensor","whose","layout","is","to","be","fetched",".","Returns",":","The","`","Layout","`","of","this","DTensor",".","Raises",":","RuntimeError",":","When","not","called","eagerly","."]
code: def fetch_layout(self, dtensor: Any) -> layout_lib.Layout:
      """Fetches the layout of the DTensor.
  
      Args:
        dtensor: The DTensor whose layout is to be fetched.
  
      Returns:
        The `Layout` of this DTensor.
  
      Raises:
        RuntimeError: When not called eagerly.
      """
      if not context.executing_eagerly():
          raise RuntimeError("`fetch_layout` must be called eagerly.")
      if _pywrap_utils.IsVariable(dtensor):
          dtensor = dtensor.read_value()
      try:
          layout_string = _pywrap_dtensor_device.FetchLayout(
              context.context()._handle,  # pylint: disable=protected-access
              dtensor,
              self._device_info,
          )
      except (
          core._NotOkStatusException
      ) as e:  # pylint: disable=protected-access
          raise core._status_to_exception(
              e
          ) from None  # pylint: disable=protected-access
  
      if layout_string is None:
          return None
      return layout_lib.Layout.from_string(layout_string)
  
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 7 for calling the DTensorDevice obj's underlying member method code with example usage: obj.fetch_layout(dtensor) and returns: layout_lib, None