class_docstr: A generalized version of all possible networks implemented using tensorflow.
class_docstr_tok: ["A","generalized","version","of","all","possible","networks","implemented","using","tensorflow","."]
docstr: Convert device to tensorflow-specific device representation
  :param device: either a specific string or method (used in distributed mode) which is returned without
      any change or a Device type, which will be converted to a string
  :return: tensorflow-specific string for device
docstr_tok: ["Convert","device","to","tensorflow-specific","device","representation",":","param","device",":","either","a","specific","string","or","method","(","used","in","distributed","mode",")","which","is","returned","without","any","change","or","a","Device","type",",","which","will","be","converted","to","a","string",":","return",":","tensorflow-specific","string","for","device"]
code: def _tf_device(device: Union[str, MethodType, Device]) -> str:
      """
      Convert device to tensorflow-specific device representation
      :param device: either a specific string or method (used in distributed mode) which is returned without
          any change or a Device type, which will be converted to a string
      :return: tensorflow-specific string for device
      """
      if isinstance(device, str) or isinstance(device, MethodType):
          return device
      elif isinstance(device, Device):
          if device.device_type == DeviceType.CPU:
              return "/cpu:0"
          elif device.device_type == DeviceType.GPU:
              return "/device:GPU:{}".format(device.index)
          else:
              raise ValueError(
                  "Invalid device_type: {}".format(device.device_type)
              )
      else:
          raise ValueError(
              "Invalid device instance type: {}".format(type(device))
          )
  
imports: import copy
  from types import MethodType
  from typing import Dict, List, Union
  import numpy
  import tensorflow
  from rl_coach.architectures.embedder_parameters import InputEmbedderParameters
  from rl_coach.architectures.head_parameters import HeadParameters
  from rl_coach.architectures.middleware_parameters import MiddlewareParameters
  from rl_coach.architectures.tensorflow_components.architecture import TensorFlowArchitecture
  from rl_coach.architectures.tensorflow_components import utils
  from rl_coach.base_parameters import AgentParameters, Device, DeviceType, EmbeddingMergerType
  from rl_coach.core_types import PredictionType
  from rl_coach.logger import screen
  from rl_coach.spaces import SpacesDefinition, PlanarMapsObservationSpace, TensorObservationSpace
  from rl_coach.utils import get_all_subclasses, dynamic_import_and_instantiate_module_from_params, indent_string
label_desc: Use image node_id 2 for calling the GeneralTensorFlowNetwork obj's underlying member method code with example usage: obj._tf_device(device) and returns: device, str, str