<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_extra_tags(self, image_id, main_tag, extra_tags, add_latest):
 """ Adds extra tags to an image after de-duplicating tag names. :param image_id: Id of the image. :type image_id: unicode | str :param main_tag: Repo / tag specification that has been used to build the image. If present, the tag will be removed from further arguments. :type main_tag: unicode | str :param extra_tags: Additional tags to add to the image. :type extra_tags: list | tuple | set | NoneType :param add_latest: Whether to add a ``latest`` tag to the image. :type add_latest: bool """

        repo, __, i_tag = main_tag.rpartition(':')
        tag_set = set(extra_tags or ())
        if add_latest:
            tag_set.add('latest')
        tag_set.discard(i_tag)
        added_tags = []
        tag_kwargs = {}
        if str(self.api_version) < DEPRECATED_FORCE_TAG_VERSION:
            tag_kwargs['force'] = True
        if repo and tag_set:
            for t in tag_set:
                try:
                    self.tag(image_id, repo, t, **tag_kwargs)
                except:
                    exc_info = sys.exc_info()
                    raise PartialResultsError(exc_info, added_tags)
                else:
                    added_tags.append(t)
        return added_tags