<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def expand(self, tags, clique_scoring_func=None):
 """This is the main function to expand tags into cliques Args: tags (list):
 a list of tags to find the cliques. clique_scoring_func (func):
 a function that returns a float value for the clique Returns: list : a list of cliques """

        lattice = Lattice()
        overlapping_spans = []

        def end_token_index():
            return max([t.get('end_token') for t in overlapping_spans])

        for i in xrange(len(tags)):
            tag = tags[i]

            if len(overlapping_spans) > 0 and end_token_index() >= tag.get('start_token'):
                overlapping_spans.append(tag)
            elif len(overlapping_spans) > 1:
                cliques = list(self._sub_expand(overlapping_spans))
                if clique_scoring_func:
                    cliques = sorted(cliques, key=lambda e: -1 * clique_scoring_func(e))
                lattice.append(cliques)
                overlapping_spans = [tag]
            else:
                lattice.append(overlapping_spans)
                overlapping_spans = [tag]
        if len(overlapping_spans) > 1:
            cliques = list(self._sub_expand(overlapping_spans))
            if clique_scoring_func:
                    cliques = sorted(cliques, key=lambda e: -1 * clique_scoring_func(e))
            lattice.append(cliques)
        else:
            lattice.append(overlapping_spans)

        return lattice.traverse()