To enhance the temporal refinement stage for handling rare and popular event boundaries more effectively, several strategies can be implemented. One approach is to incorporate a dynamic thresholding mechanism that adapts to the distribution of boundaries in the video sequence. By analyzing the density of boundaries and the temporal distance between them, the algorithm can adjust the threshold dynamically to capture both rare and popular boundaries accurately. Additionally, introducing a clustering algorithm that considers the temporal proximity and similarity of boundaries can help group together related boundaries, improving the overall refinement process. By combining these techniques, the temporal refinement stage can better handle a variety of event boundary scenarios, including rare and popular boundaries.