def query_and_replace(self, keys, reader_fn, offset=0):
        """Queries the cache. Then inserts the keys that are not found by
        reading them by calling `reader_fn(missing_keys)`, which are then
        inserted into the cache using the selected caching policy algorithm
        to remove the old entries if it is full.

        Parameters
        ----------
        keys : Tensor
            The keys to query the cache with.
        reader_fn : reader_fn(keys: torch.Tensor) -> torch.Tensor
            A function that will take a missing keys tensor and will return
            their values.
        offset : int
            The offset to be added to the keys. Default is 0.

        Returns
        -------
        Tensor
            A tensor containing values corresponding to the keys. Should equal
            `reader_fn(keys)`, computed in a faster way.
        """
        self.total_queries += keys.shape[0]
        (
            positions,
            index,
            pointers,
            missing_keys,
            found_offsets,
            missing_offsets,
        ) = self._policy.query_and_replace(keys, offset)
        found_cnt = keys.size(0) - missing_keys.size(0)
        found_positions = positions[:found_cnt]
        values = self._cache.query(found_positions, index, keys.shape[0])
        found_pointers = pointers[:found_cnt]
        self._policy.reading_completed(found_pointers, found_offsets)
        self.total_miss += missing_keys.shape[0]
        missing_index = index[found_cnt:]
        missing_values = reader_fn(missing_keys)
        values[missing_index] = missing_values
        missing_positions = positions[found_cnt:]
        self._cache.replace(missing_positions, missing_values)
        missing_pointers = pointers[found_cnt:]
        self._policy.writing_completed(missing_pointers, missing_offsets)
        return values
Queries the cache. Then inserts the keys that are not found by
        reading them by calling `reader_fn(missing_keys)`, which are then
        inserted into the cache using the selected caching policy algorithm
        to remove the old entries if it is full.

        Parameters
        ----------
        keys : Tensor
            The keys to query the cache with.
        reader_fn : reader_fn(keys: torch.Tensor) -> torch.Tensor
            A function that will take a missing keys tensor and will return
            their values.
        offset : int
            The offset to be added to the keys. Default is 0.

        Returns
        -------
        Tensor
            A tensor containing values corresponding to the keys. Should equal
            `reader_fn(keys)`, computed in a faster way.
        
python/dgl/graphbolt/impl/cpu_feature_cache.py