def find_similar_template(self, next_possible_states, message):
        """ Get most similar template and its fields to a message
        for next possible transitions.
        """

        for state in next_possible_states:
            try:
                id_list = self.state_id[state[0]]
            except __HOLE__:
                continue
            templates = []
            for id in id_list:
                template = self.template_dic[id]
                matcher = SimilarTemplateMessageMatcher(template, message,
                                                        self.lexerStyle)
                fields, dist = matcher.match()
                templates += [(template, fields, distance)]
            sorted_templates = [(t, f, d) for t, f, d in sorted(templates,
                                              key=lambda (t, f, d): (d, t, f))]
            template, fields = sorted_templates[0][:2]
            return (template, fields)
dataset/ETHPy150Open hgascon/pulsar/pulsar/core/lens.py/TemplateList.find_similar_template