def refine_many_to_many_related_manager(ctx: MethodContext) -> MypyType:
    """
    Updates the 'ManyRelatedManager' returned by e.g. 'ManyToManyDescriptor' to be a subclass
    of 'ManyRelatedManager' and the related model's default manager.
    """
    related_objects = get_related_manager_and_model(ctx)
    if related_objects is None:
        return ctx.default_return_type

    many_related_manager, related_model_instance, through_model_instance = related_objects
    checker = helpers.get_typechecker_api(ctx)
    related_manager_info = helpers.get_many_to_many_manager_info(
        checker, to=related_model_instance.type, derived_from="_default_manager"
    )
    if related_manager_info is None:
        return ctx.default_return_type
    return Instance(related_manager_info, [through_model_instance])

    Updates the 'ManyRelatedManager' returned by e.g. 'ManyToManyDescriptor' to be a subclass
    of 'ManyRelatedManager' and the related model's default manager.
    
mypy_django_plugin/transformers/manytomany.py