code: def _difference(self, original_keys, updated_keys, name, item_index):
          
          original_keys = set(original_keys)
          updated_keys = set(updated_keys)
          added_keys = updated_keys.difference(original_keys)
          removed_keys = set()
          if name is None:
              removed_keys = original_keys.difference(updated_keys)
          elif name not in updated_keys and name in original_keys:
              removed_keys = set([name])
  
          for key in removed_keys:
              if key in item_index:
                  del(item_index[key])
  
          # Check the keys that was not added now or not lined up for removal,
          # and see if they changed.
          for key in updated_keys.difference(added_keys.union(removed_keys)):
              if item_index[key].get('_changed'):
                  item_index[key]['_changed'] = False
                  removed_keys.add(key)
                  added_keys.add(key)
  
          return added_keys, removed_keys
docs: Calculate difference between the original and updated sets of keys.
  
          Removed items will be removed from item_index, new items should have
          been added by the discovery process. (?help or ?sensor-list)
  
          This method is for use in inspect_requests and inspect_sensors only.
  
          Returns
          -------
  
          (added, removed)
          added : set of str
              Names of the keys that were added
          removed : set of str
              Names of the keys that were removed