def METHOD_NAME(self, codes, hierarchy):
    """Group codes by their Type"""
    # create a lookup of code -> type
    code_to_type = {
        code: type.title()
        for code, (_, type) in self.code_to_term_and_type(codes).items()
    }
    code_to_active = {
        concept.id: concept.active
        for concept in Concept.objects.using(self.database_alias).filter(
            id__in=codes
        )
    }
    lookup = collections.defaultdict(list)
    for code in codes:
        type = code_to_type.get(code)
        if type is None:
            lookup["[unknown]"].append(code)
        elif code_to_active[code]:
            lookup[type].append(code)
        else:
            lookup[f"[inactive] {type}"].append(code)
    return dict(lookup)