human
Complete this python program:
def _pack_instance_onto_cores(available_siblings, instance_cell, host_cell_id, threads_per_core=1, num_cpu_reserved=0):
assistant
#Here is the Python code you requested.

    """Pack an instance onto a set of siblings.
    Calculate the pinning for the given instance and its topology,
    making sure that hyperthreads of the instance match up with those
    of the host when the pinning takes effect. Also ensure that the
    physical cores reserved for hypervisor on this host NUMA node do
    not break any thread policies.
    Currently the strategy for packing is to prefer siblings and try use
    cores evenly by using emptier cores first. This is achieved by the
    way we order cores in the sibling_sets structure, and the order in
    which we iterate through it.
    The main packing loop that iterates over the sibling_sets dictionary
    will not currently try to look for a fit that maximizes number of
    siblings, but will simply rely on the iteration ordering and picking
    the first viable placement.
    :param available_siblings: list of sets of CPU IDs corresponding to
    available siblings per core
    :param instance_cell: An instance of objects.InstanceNUMACell
    describing the pinning requirements of the
    instance
    :param threads_per_core: number of threads per core in host\s cell
    :param num_cpu_reserved: number of pCPUs reserved for hypervisor
    :returns: An instance of objects.InstanceNUMACell containing the
    pinning information, the physical cores reserved and
    potentially a new topology to be exposed to the
    instance. None if there is no valid way to satisfy the
    sibling requirements for the instance.
    """
    LOG.debug('Packing    an    instance    onto    a    set    of    siblings:                    available_siblings:    %(siblings)s                instance_cell:    %(cells)s                host_cell_id:    %(host_cell_id)s                threads_per_core:    %(threads_per_core)s', {'siblings': available_siblings, 'cells': instance_cell, 'host_cell_id': host_cell_id, 'threads_per_core': threads_per_core})
    sibling_sets = collections.defaultdict(list)
    for sib in available_siblings:
        for threads_no in range(1, (len(sib) + 1)):
            sibling_sets[threads_no].append(sib)
    LOG.debug('Built    sibling_sets:    %(siblings)s', {'siblings': sibling_sets})
    pinning = None
    threads_no = 1
    def _orphans(instance_cell, threads_per_core):
        'Number    of    instance    CPUs    which    will    not    fill    up    a    host    core.\n\n                                Best    explained    by    an    example:    consider    set    of    free    host    cores    as    such:\n                                                [(0,    1),    (3,    5),    (6,    7,    8)]\n                                This    would    be    a    case    of    2    threads_per_core    AKA    an    entry    for    2    in    the\n                                sibling_sets    structure.\n\n                                If    we    attempt    to    pack    a    5    core    instance    on    it    -    due    to    the    fact    that    we\n                                iterate    the    list    in    order,    we    will    end    up    with    a    single    core    of    the\n                                instance    pinned    to    a    thread    "alone"    (with    id    6),    and    we    would    have    one\n                                \'orphan\'    vcpu.\n                                '
        return (len(instance_cell) % threads_per_core)
    def _threads(instance_cell, threads_per_core):
        "Threads    to    expose    to    the    instance    via    the   ...