code: def is_xla_available():
      """Is XLA compilation available for the current device context?"""
  
      global _IS_XLA_AVAILABLE
      # There's unfortunately no cleaner way to get the device other than creating a
      # new op and querying it.
      with tf.name_scope("is_xla_available"):
          device = tf.constant(0.0).device
      if device not in _IS_XLA_AVAILABLE:
          try:
              # Take ourselves outside of any tf.function calls.
              with tf.init_scope():
                  # Create temporary xla subgraph
                  with tf.compat.v1.Graph().as_default():
                      # We'll use a session so we can be compatible with both TF1 and TF2
                      with tf.compat.v1.Session() as sess:
                          # Check for XLA on the given device.
                          with tf.device(device):
                              sess.run(
                                  tf.xla.experimental.compile(
                                      lambda: tf.constant(0.0)
                                  )
                              )
          except (ValueError, tf.errors.InvalidArgumentError):
              _IS_XLA_AVAILABLE[device] = False
          else:
              _IS_XLA_AVAILABLE[device] = True
      return _IS_XLA_AVAILABLE[device]
  
file_path: agents/tf_agents/utils/xla.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import functools
  import tensorflow
label_desc: Use image node_id 1 for calling a global function with example usage: is_xla_available() and returns: _IS_XLA_AVAILABLE