code: def device(request):
      try:
          requested_device = request.param
      except Exception:
          # workaround for DocTestItem
          # https://github.com/pytest-dev/pytest/issues/5070
          requested_device = "no_device"
      if requested_device == "no_device":
          yield requested_device
      elif requested_device == tf.distribute.MirroredStrategy:
          strategy = requested_device(gpus_for_testing())
          with strategy.scope():
              yield strategy
      elif isinstance(requested_device, str):
          if requested_device == "gpu":
              # we use GPU:0 because the virtual device we created is the
              # only one in the first GPU (so first in the list of virtual devices).
              requested_device += ":0"
          elif requested_device == "cpu":
              requested_device = "cpu"
          else:
              raise KeyError("Invalid device: " + requested_device)
          with tf.device(requested_device):
              yield requested_device
  
imports: import os
  import random
  import inspect
  import numpy
  import pytest
  import tensorflow
  from tensorflow_addons import options
  from tensorflow_addons.utils import resource_loader
  from tensorflow_addons.utils.tf_test_utils import layer_test
label_desc: Use image node_id 14 for calling a global function with example usage: device(request) without return types