import torch


def get_avg_global_features(points, mask, features, model):
    """obtain the avg pooling global features
    Args:
        points ([type]): points_batch
        mask ([type]): points mask
        features ([type]): point features
        model ([type]): the loaded model
    Returns:
        [type]: return the avg global features
    """
    with torch.no_grad():
        output = None
        
        def hook_func(module_, input_, output_):
            nonlocal output
            output = output_

        # the model's name(pool_avg) is determined by the classifer definition
        hook = model.module.classifier.pool_avg.register_forward_hook(hook_func)        
        model(points, mask, features) # (B,num_classes)
        hook.remove()

        return output