def METHOD_NAME(cls, sub) -> "GenericSubtitle":
    if isinstance(sub, srt.Subtitle):
        return cls(sub.start, sub.end, sub)
    elif isinstance(sub, pysubs2.SSAEvent):
        return cls(
            timedelta(milliseconds=sub.start), timedelta(milliseconds=sub.end), sub
        )
    else:
        raise NotImplementedError("unsupported subtitle type: %s" % type(sub))