code: def add_device(self, resource_name, device):
          
  
          if device.resource_name is not None:
              msg = 'The device %r is already assigned to %s'
              raise ValueError(msg % (device, device.resource_name))
  
          device.resource_name = resource_name
  
          self._internal[device.resource_name] = device
docs: Bind device to resource name