def gsea_compute_tensor(data, gmt, n, weighted_score_type, permutation_type,<EOL>method, pheno_pos, pheno_neg, classes, ascending,<EOL>processes=<NUM_LIT:1>, seed=None, single=False, scale=False):
w = weighted_score_type<EOL>subsets = sorted(gmt.keys())<EOL>rs = np.random.RandomState(seed)<EOL>genes_mat, cor_mat = data.index.values, data.values<EOL>base = <NUM_LIT:5> if data.shape[<NUM_LIT:0>] >= <NUM_LIT> else <NUM_LIT:10><EOL>block = ceil(len(subsets) / base)<EOL>if permutation_type == "<STR_LIT>":<EOL><INDENT>logging.debug("<STR_LIT>")<EOL>genes_ind = []<EOL>cor_mat = []<EOL>temp_rnk = []<EOL>pool_rnk = Pool(processes=processes)<EOL>i=<NUM_LIT:1><EOL>while i <= block:<EOL><INDENT>rs = np.random.RandomState(seed)<EOL>temp_rnk.append(pool_rnk.apply_async(ranking_metric_tensor,<EOL>args=(data, method, base, pheno_pos, pheno_neg, classes,<EOL>ascending, rs)))<EOL>i +=<NUM_LIT:1><EOL><DEDENT>pool_rnk.close()<EOL>pool_rnk.join()<EOL>for k, temp in enumerate(temp_rnk):<EOL><INDENT>gi, cor = temp.get()<EOL>if k+<NUM_LIT:1> == block:<EOL><INDENT>genes_ind.append(gi)<EOL>cor_mat.append(cor)<EOL><DEDENT>else:<EOL><INDENT>genes_ind.append(gi[:-<NUM_LIT:1>])<EOL>cor_mat.append(cor[:-<NUM_LIT:1>])<EOL><DEDENT><DEDENT>genes_ind, cor_mat = np.vstack(genes_ind), np.vstack(cor_mat)<EOL>genes_mat = (data.index.values, genes_ind)<EOL><DEDENT>logging.debug("<STR_LIT>")<EOL>es = []<EOL>RES = []<EOL>hit_ind = []<EOL>esnull = []<EOL>temp_esnu = []<EOL>pool_esnu = Pool(processes=processes)<EOL>i, m = <NUM_LIT:1>, <NUM_LIT:0><EOL>while i <= block:<EOL><INDENT>rs = np.random.RandomState(seed)<EOL>gmtrim = {k: gmt.get(k) for k in subsets[m:base * i]}<EOL>temp_esnu.append(pool_esnu.apply_async(enrichment_score_tensor,<EOL>args=(genes_mat, cor_mat,<EOL>gmtrim, w, n, rs,<EOL>single, scale)))<EOL>m = base * i<EOL>i += <NUM_LIT:1><EOL><DEDENT>pool_esnu.close()<EOL>pool_esnu.join()<EOL>for si, temp in enumerate(temp_esnu):<EOL><INDENT>e, enu, hit, rune = temp.get()<EOL>esnull.append(enu)<EOL>es.append(e)<EOL>RES.append(rune)<EOL>hit_ind += hit<EOL><DEDENT>es, esnull, RES = np.hstack(es), np.vstack(esnull), np.vstack(RES)<EOL>return gsea_significance(es, esnull), hit_ind, RES, subsets<EOL>
compute enrichment scores and enrichment nulls.

        :param data: preprocessed expression dataframe or a pre-ranked file if prerank=True.
        :param dict gmt: all gene sets in .gmt file. need to call load_gmt() to get results.
        :param int n: permutation number. default: 1000.
        :param str method: ranking_metric method. see above.
        :param str pheno_pos: one of labels of phenotype's names.
        :param str pheno_neg: one of labels of phenotype's names.
        :param list classes: a list of phenotype labels, to specify which column of dataframe belongs to what category of phenotype.
        :param float weighted_score_type: default:1
        :param bool ascending: sorting order of rankings. Default: False.
        :param seed: random seed. Default: np.random.RandomState()
        :param bool scale: if true, scale es by gene number.

        :return: a tuple contains::

                | zipped results of es, nes, pval, fdr.
                | nested list of hit indices of input gene_list.
                | nested list of ranked enrichment score of each input gene_sets.
                | list of enriched terms