<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def encode(self, tags, encoding, values_to_sub):
 """ reads the encoding type from the event-mapping.json and determines whether a value needs encoding Parameters tags: dict the values of a particular event that can be substituted within the event json encoding: string string that helps navigate to the encoding field of the json values_to_sub: dict key/value pairs that will be substituted into the json Returns ------- values_to_sub: dict the encoded (if need be) values to substitute into the json. """


        for tag in tags:
            if tags[tag].get(encoding) != "None":
                if tags[tag].get(encoding) == "url":
                    values_to_sub[tag] = self.url_encode(values_to_sub[tag])
                if tags[tag].get(encoding) == "base64":
                    values_to_sub[tag] = self.base64_utf_encode(values_to_sub[tag])
        return values_to_sub