code: def get_device(device: Any) -> Any:
      import tensorflow as tf
  
      if device is None:
          device = tf.device(
              "/GPU:0" if tf.test.is_gpu_available() else "/CPU:0"
          )
      if isinstance(device, str):
          device = tf.device(device)
      return device
  
file_path: foolbox/foolbox/models/tensorflow.py
imports: from typing import cast, Any
  import eagerpy
  from ..types import BoundsInput, Preprocessing
  from .base import ModelWithPreprocessing
label_desc: Use image node_id 1 for calling a global function with example usage: get_device(device) and returns: device