def compacify(train_seq, test_seq, dev_seq, theano=False):

    # REDO DICTS
    new_x_dict = LabelDictionary()
    new_y_dict = LabelDictionary(['noun'])
    for corpus_seq in [train_seq, test_seq, dev_seq]:
        for seq in corpus_seq:
            for index in seq.x:
                word = corpus_seq.x_dict.get_label_name(index)
                if word not in new_x_dict:
                    new_x_dict.add(word)
            for index in seq.y:
                tag = corpus_seq.y_dict.get_label_name(index)
                if tag not in new_y_dict:
                    new_y_dict.add(tag)

#    import copy
#    train_seq2, test_seq2, dev_seq2 = copy.deepcopy(train_seq), copy.deepcopy(test_seq), copy.deepcopy(dev_seq)
    
    # REDO INDICES
    #for corpus_seq in [train_seq2, test_seq2, dev_seq2]:
    for corpus_seq in [train_seq, test_seq, dev_seq]:
        for seq in corpus_seq:
            for i in seq.x:
                if corpus_seq.x_dict.get_label_name(i) not in new_x_dict:
                    import ipdb;ipdb.set_trace() 
                    pass
            for i in seq.y:
                if corpus_seq.y_dict.get_label_name(i) not in new_y_dict:
                    import ipdb;ipdb.set_trace() 
                    pass
            seq.x = [new_x_dict[corpus_seq.x_dict.get_label_name(i)] for i in seq.x]
            seq.y = [new_y_dict[corpus_seq.y_dict.get_label_name(i)] for i in seq.y]
            # For compatibility with GPUs store as numpy arrays and cats to int
            # 32
            if theano:
                seq.x = np.array(seq.x, dtype='int32')
                seq.y = np.array(seq.y, dtype='int32')
        # Reinstate new dicts
        corpus_seq.x_dict = new_x_dict
        corpus_seq.y_dict = new_y_dict

    # SANITY CHECK:
    # These must be the same
#    tmap  = {v: k for k, v in train_seq.x_dict.items()}
#    tmap2 = {v: k for k, v in train_seq2.x_dict.items()}
#    import ipdb;ipdb.set_trace()
#    [tmap[i] for i in train_seq[0].x] 
#    [tmap2[i] for i in train_seq2[0].x]

    return train_seq, test_seq, dev_seq
Create a map for indices that is be compact (do not have unused indices)
dataset/ETHPy150Open LxMLS/lxmls-toolkit/lxmls/readers/pos_corpus.py/compacify