code: def _get_first_available_accelerator_type(
      wishlist: Sequence[str] = ("TPU", "GPU", "CPU")
  ) -> str:
      """Returns the first available accelerator type listed in a wishlist.
  
      Args:
        wishlist: A sequence of elements from {'CPU', 'GPU', 'TPU'}, listed in
          order of descending preference.
  
      Returns:
        The first available accelerator type from `wishlist`.
  
      Raises:
        RuntimeError: Thrown if no accelerators from the `wishlist` are found.
      """
      get_visible_devices = tf.config.get_visible_devices
  
      for wishlist_device in wishlist:
          devices = get_visible_devices(device_type=wishlist_device)
          if devices:
              return wishlist_device
  
      available = ", ".join(
          sorted(frozenset([d.type for d in get_visible_devices()]))
      )
      raise RuntimeError(
          "Couldn't find any devices from {wishlist}."
          + f"Only the following types are available: {available}."
      )
  
imports: import copy
  import dataclasses
  import functools
  from typing import Iterator, List, Optional, Tuple, Union, Sequence
  from acme import adders
  from acme import core
  from acme import datasets
  from acme import specs
  from acme import types
  from acme.adders import reverb
  from acme.agents import agent
  from acme.agents.tf import actors
  from acme.agents.tf.d4pg import learning
  from acme.tf import networks
  from acme.tf import utils
  from acme.tf import variable_utils
  from acme.utils import counting
  from acme.utils import loggers
  import reverb
  import sonnet
  import tensorflow
label_desc: Use image node_id 2 for calling a global function with example usage: _get_first_available_accelerator_type(wishlist) and returns: wishlist_device