<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def nl_socket_drop_memberships(sk, *group):
 """Leave groups. https://github.com/thom311/libnl/blob/libnl3_2_25/lib/socket.c#L465 Leaves the specified groups using the modern socket option. The list of groups has to terminated by 0. Positional arguments: sk -- Netlink socket (nl_sock class instance). group -- group identifier (integer). Returns: 0 on success or a negative error code. """

    if sk.s_fd == -1:
        return -NLE_BAD_SOCK
    for grp in group:
        if not grp:
            break
        if grp < 0:
            return -NLE_INVAL
        try:
            sk.socket_instance.setsockopt(SOL_NETLINK, NETLINK_DROP_MEMBERSHIP, grp)
        except OSError as exc:
            return -nl_syserr2nlerr(exc.errno)
    return 0