<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def init_swarm(self, advertise_addr=None, listen_addr='0.0.0.0:2377', force_new_cluster=False, swarm_spec=None, default_addr_pool=None, subnet_size=None):
 """ Initialize a new Swarm using the current connected engine as the first node. Args: advertise_addr (string):
 Externally reachable address advertised to other nodes. This can either be an address/port combination in the form ``192.168.1.1:4567``, or an interface followed by a port number, like ``eth0:4567``. If the port number is omitted, the port number from the listen address is used. If ``advertise_addr`` is not specified, it will be automatically detected when possible. Default: None listen_addr (string):
 Listen address used for inter-manager communication, as well as determining the networking interface used for the VXLAN Tunnel Endpoint (VTEP). This can either be an address/port combination in the form ``192.168.1.1:4567``, or an interface followed by a port number, like ``eth0:4567``. If the port number is omitted, the default swarm listening port is used. Default: '0.0.0.0:2377' force_new_cluster (bool):
 Force creating a new Swarm, even if already part of one. Default: False swarm_spec (dict):
 Configuration settings of the new Swarm. Use ``APIClient.create_swarm_spec`` to generate a valid configuration. Default: None default_addr_pool (list of strings):
 Default Address Pool specifies default subnet pools for global scope networks. Each pool should be specified as a CIDR block, like '10.0.0.0/8'. Default: None subnet_size (int):
 SubnetSize specifies the subnet size of the networks created from the default subnet pool. Default: None Returns: ``True`` if successful. Raises: :py:class:`docker.errors.APIError` If the server returns an error. """


        url = self._url('/swarm/init')
        if swarm_spec is not None and not isinstance(swarm_spec, dict):
            raise TypeError('swarm_spec must be a dictionary')

        if default_addr_pool is not None:
            if utils.version_lt(self._version, '1.39'):
                raise errors.InvalidVersion(
                    'Address pool is only available for API version >= 1.39'
                )
            # subnet_size becomes 0 if not set with default_addr_pool
            if subnet_size is None:
                subnet_size = DEFAULT_SWARM_SUBNET_SIZE

        if subnet_size is not None:
            if utils.version_lt(self._version, '1.39'):
                raise errors.InvalidVersion(
                    'Subnet size is only available for API version >= 1.39'
                )
            # subnet_size is ignored if set without default_addr_pool
            if default_addr_pool is None:
                default_addr_pool = DEFAULT_SWARM_ADDR_POOL

        data = {
            'AdvertiseAddr': advertise_addr,
            'ListenAddr': listen_addr,
            'DefaultAddrPool': default_addr_pool,
            'SubnetSize': subnet_size,
            'ForceNewCluster': force_new_cluster,
            'Spec': swarm_spec,
        }
        response = self._post_json(url, data=data)
        self._raise_for_status(response)
        return True