def get_model_of_related_manager(ctx: MethodContext) -> Instance | None:
    """
    Returns the type parameter (_To) instance of a `RelatedManager` instance when it's a
    model. Otherwise `None` is returned.

    For example: if given a `RelatedManager[A]` where `A` is a model then `A` is
    returned.
    """
    default_return_type = get_proper_type(ctx.default_return_type)
    if (
        isinstance(default_return_type, Instance)
        and default_return_type.type.fullname == fullnames.RELATED_MANAGER_CLASS
    ):
        # This is a call to '__get__' overload with a model instance of
        # 'ReverseManyToOneDescriptor'. Returning a 'RelatedManager'. Which we want to,
        # just like Django, build from the default manager of the related model.
        related_manager = default_return_type
        # Require first type argument of 'RelatedManager' to be a model
        if (
            len(related_manager.args) >= 1
            and isinstance((_To := get_proper_type(related_manager.args[0])), Instance)
            and helpers.is_model_type(_To.type)
        ):
            return _To

    return None

    Returns the type parameter (_To) instance of a `RelatedManager` instance when it's a
    model. Otherwise `None` is returned.

    For example: if given a `RelatedManager[A]` where `A` is a model then `A` is
    returned.
    
mypy_django_plugin/transformers/manytoone.py