code: def _marshal_claims(self, query_claims):
          
          claims = reduce_claims(query_claims)
          # self.data['claimq'] = query_claims
          self.data['claims'] = claims
  
          entities = set()
          for eid in claims:
              if self.user_labels:
                  if eid in self.user_labels or eid == 'P31':
                      entities.add(eid)  # P (property)
                  else:
                      continue  # get only wanted entities
              else:
                  entities.add(eid)  # P (property)
  
              for val in claims[eid]:
                  if utils.is_text(val) and re.match(r'^Q\d+$', val):
                      entities.add(val)  # Q (item)
  
          self.data['entities'] = list(entities)
docs: set Wikidata entities from query claims