<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 async def initialize(bot: Bot, host, password, rest_port, ws_port, timeout=30):
 """ Initializes the websocket connection to the lavalink player. .. important:: This function must only be called AFTER the bot has received its "on_ready" event! Parameters bot : Bot An instance of a discord.py `Bot` object. host : str The hostname or IP address of the Lavalink node. password : str The password of the Lavalink node. rest_port : int The port of the REST API on the Lavalink node. ws_port : int The websocket port on the Lavalink Node. timeout : int Amount of time to allow retries to occur, ``None`` is considered forever. """

    global _loop
    _loop = bot.loop

    player_manager.user_id = bot.user.id
    player_manager.channel_finder_func = bot.get_channel
    register_event_listener(_handle_event)
    register_update_listener(_handle_update)

    lavalink_node = node.Node(
        _loop,
        dispatch,
        bot._connection._get_websocket,
        host,
        password,
        port=ws_port,
        rest=rest_port,
        user_id=player_manager.user_id,
        num_shards=bot.shard_count if bot.shard_count is not None else 1,
    )

    await lavalink_node.connect(timeout=timeout)

    bot.add_listener(node.on_socket_response)
    bot.add_listener(_on_guild_remove, name="on_guild_remove")

    return lavalink_node