<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def magnet(self, name=True, size=True, trackers=True, tracker=False, validate=True):
 """ BTIH Magnet URI :param bool name: Whether to include the name :param bool size: Whether to include the size :param bool trackers: Whether to include all trackers :param bool tracker: Whether to include only the first tracker of the first tier (overrides `trackers`) :param bool validate: Whether to run :meth:`validate` first """

        if validate:
            self.validate()

        parts = [f'xt=urn:btih:{self.infohash}']
        if name:
            parts.append(f'dn={utils.urlquote(self.name)}')
        if size:
            parts.append(f'xl={self.size}')

        if self.trackers is not None:
            if tracker:
                parts.append(f'tr={utils.urlquote(self.trackers[0][0])}')
            elif trackers:
                for tier in self.trackers:
                    for url in tier:
                        parts.append(f'tr={utils.urlquote(url)}')

        return 'magnet:?' + '&'.join(parts)