<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def labels(self, qids):
 """ Returns Wikidata labels query string """

        if len(qids) > 50:
            raise ValueError("The limit is 50.")

        self.domain = 'www.wikidata.org'
        self.uri = self.wiki_uri(self.domain)

        query = self.WIKIDATA.substitute(
            WIKI=self.uri,
            ENDPOINT=self.endpoint,
            LANG=self.variant or self.lang,
            PROPS='labels')

        qids = '|'.join(qids)
        query += "&ids=%s" % qids

        self.set_status('labels', qids)

        return query