human
Complete this python program:
def _compose_mro(cls, types):
assistant
#Here is the Python code you requested.

    """Calculates the method resolution order for a given class *cls*.
    Includes relevant abstract base classes (with their respective bases) from
    the *types* iterable. Uses a modified C3 linearization algorithm.
    """
    bases = set(cls.__mro__)
    def is_related(typ):
        return ((typ not in bases) and hasattr(typ, u'__mro__') and issubclass(cls, typ))
    types = [n for n in types if is_related(n)]
    def is_strict_base(typ):
        for other in types:
            if ((typ != other) and (typ in other.__mro__)):
                return True
        return False
    types = [n for n in types if (not is_strict_base(n))]
    type_set = set(types)
    mro = []
    for typ in types:
        found = []
        for sub in typ.__subclasses__():
            if ((sub not in bases) and issubclass(cls, sub)):
                found.append([s for s in sub.__mro__ if (s in type_set)])
        if (not found):
            mro.append(typ)
            continue
        found.sort(key=len, reverse=True)
        for sub in found:
            for subcls in sub:
                if (subcls not in mro):
                    mro.append(subcls)
    return _c3_mro(cls, abcs=mro)