'Get a list of indices, creating new tensor indices to complete dummy indices.'

def get_indices(self):

    components = self.components
    free = self.free
    dum = self.dum
    indices = ([None] * self._ext_rank)
    start = 0
    pos = 0
    vpos = []
    for t in components:
        vpos.append(pos)
        pos += t.rank
    cdt = defaultdict(int)
    for (indx, ipos, cpos) in free:
        if (indx._name.split('_')[0] == indx.tensor_index_type._dummy_fmt[:(-3)]):
            cdt[indx.tensor_index_type] = max(cdt[indx.tensor_index_type], (int(indx._name.split('_')[1]) + 1))
        start = vpos[cpos]
        indices[(start + ipos)] = indx
    for (ipos1, ipos2, cpos1, cpos2) in dum:
        start1 = vpos[cpos1]
        start2 = vpos[cpos2]
        typ1 = components[cpos1].index_types[ipos1]
        assert (typ1 == components[cpos2].index_types[ipos2])
        fmt = typ1._dummy_fmt
        nd = cdt[typ1]
        indices[(start1 + ipos1)] = TensorIndex((fmt % nd), typ1)
        indices[(start2 + ipos2)] = TensorIndex((fmt % nd), typ1, False)
        cdt[typ1] += 1
    return indices
