<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def publish(self, topic, data, defer=None):
 """Publish a message to the given topic over http. :param topic: the topic to publish to :param data: bytestring data to publish :param defer: duration in millisconds to defer before publishing (requires nsq 0.3.6) """

        nsq.assert_valid_topic_name(topic)
        fields = {'topic': topic}

        if defer is not None:
            fields['defer'] = '{}'.format(defer)

        return self._request('POST', '/pub', fields=fields, body=data)