private CompletableFuture<Void> invokeOnPartitionsRevokedOrLostToReleaseAssignment() {
        SortedSet<TopicPartition> droppedPartitions = new TreeSet<>(TOPIC_PARTITION_COMPARATOR);
        droppedPartitions.addAll(subscriptions.assignedPartitions());

        log.info("Member {} is triggering callbacks to release assignment {} and leave group",
            memberId, droppedPartitions);

        CompletableFuture<Void> callbackResult;
        if (droppedPartitions.isEmpty()) {
            // No assignment to release.
            callbackResult = CompletableFuture.completedFuture(null);
        } else {
            // Release assignment.
            if (memberEpoch > 0) {
                // Member is part of the group. Invoke onPartitionsRevoked.
                callbackResult = revokePartitions(droppedPartitions);
            } else {
                // Member is not part of the group anymore. Invoke onPartitionsLost.
                callbackResult = invokeOnPartitionsLostCallback(droppedPartitions);
            }
        }
        return callbackResult;
    }
Release member assignment by calling the user defined callbacks for onPartitionsRevoked or
onPartitionsLost.
<ul>
    <li>If the member is part of the group (epoch > 0), this will invoke onPartitionsRevoked.
    This will be the case when releasing assignment because the member is intentionally
    leaving the group (after a call to unsubscribe)</li>

    <li>If the member is not part of the group (epoch <=0), this will invoke onPartitionsLost.
    This will be the case when releasing assignment after being fenced .</li>
</ul>

@return Future that will complete when the callback execution completes.
clients/src/main/java/org/apache/kafka/clients/consumer/internals/MembershipManagerImpl.java