code: def _load_device(self, name, config):
          
  
          if config is None:
              config_dict = {}
          elif isinstance(config, dict):
              config_dict = config
          elif config[0] == '#':
              # Allow passing base64 encoded json directly in the port string to ease testing.
              import base64
              config_str = str(base64.b64decode(config[1:]), 'utf-8')
              config_dict = json.loads(config_str)
          else:
              try:
                  with open(config, "r") as conf:
                      data = json.load(conf)
              except IOError as exc:
                  raise ArgumentError("Could not open config file", error=str(exc), path=config)
  
              if 'device' not in data:
                  raise ArgumentError("Invalid configuration file passed to VirtualDeviceAdapter",
                                      device_name=name, config_path=config, missing_key='device')
  
              config_dict = data['device']
  
          reg = ComponentRegistry()
  
          if name.endswith('.py'):
              _name, device_factory = reg.load_extension(name, class_filter=VirtualIOTileDevice, unique=True)
              return device_factory(config_dict)
  
          seen_names = []
          for device_name, device_factory in reg.load_extensions('iotile.virtual_device',
                                                                 class_filter=VirtualIOTileDevice,
                                                                 product_name="virtual_device"):
              if device_name == name:
                  return device_factory(config_dict)
  
              seen_names.append(device_name)
  
          raise ArgumentError("Could not find virtual_device by name", name=name, known_names=seen_names)
docs: Load a device either from a script or from an installed module