human
Complete this python program:
def do_launch(cls, address='127.0.0.1', port=6633, max_retry_delay=16, dpid=None, extra_args=None, **kw):
assistant
#Here is the Python program you requested.

    """Used for implementing custom switch launching functions
    cls is the class of the switch you want to add.
    Returns switch instance.
    """
    if (extra_args is not None):
        import ast
        extra_args = ast.literal_eval(('{%s}' % (extra_args,)))
        kw.update(extra_args)
    from pox.core import core
    if (not core.hasComponent('datapaths')):
        core.register('datapaths', {})
    _switches = core.datapaths
    if (dpid is None):
        for dpid in range(1, 256):
            if (dpid not in _switches):
                break
        if (dpid in _switches):
            raise RuntimeError('Out    of    DPIDs')
    else:
        dpid = str_to_dpid(dpid)
    switch = cls(dpid=dpid, name=('sw' + str(dpid)), **kw)
    _switches[dpid] = switch
    port = int(port)
    max_retry_delay = int(max_retry_delay)
    def up(event):
        import pox.lib.ioworker
        global loop
        loop = pox.lib.ioworker.RecocoIOLoop()
        loop.start()
        OpenFlowWorker.begin(loop=loop, addr=address, port=port, max_retry_delay=max_retry_delay, switch=switch)
    from pox.core import core
    core.addListenerByName('UpEvent', up)
    return switch