    def build_retriver(
        self,
        retriever_cls=None,
        hidden_size=None,
        centroids=4096,
        db_type="flatl2",
        examples_per_cent_to_train=48
    ):
        if retriever_cls is None:
            retriever_cls = self.retriever_cls
        if hidden_size is None:
            hidden_size = self.hidden_size
        """merge results from multiple gpus and return a retriver.."""
        if torch.distributed.is_initialized():
            self.save()
            # sync saving.
            torch.distributed.barrier()
            world_size = torch.distributed.get_world_size()
        else:
            world_size = 1
        self.retriver = retriever_cls(
            hidden_size, centroids, db_type, examples_per_cent_to_train)
        # each gpu process has its own retriever.
        for local_rank in range(world_size):
            if get_local_rank() == 0:
                print("load local_rank", local_rank)
            hidden_states, video_ids = self.load(local_rank)
            hidden_states = hidden_states.astype("float32")
            self.retriver.add(hidden_states, video_ids)
        return self.retriver
merge results from multiple gpus and return a retriver..
examples/MMPT/mmpt/modules/vectorpool.py