    def count_flops(
        self,
        dataset,
        repeat,
    ):
        """Use PYPAPI library to count average flops for model inference.
        Note: It only works if the model is being run on cpu"""
        logger.info("Starting flop counter")
        high.start_counters([events.PAPI_DP_OPS])
        for i, sample in enumerate(dataset):
            for _r in range(repeat):
                self.forward(sample)
            if i % 100 == 0:
                logger.info(f"Counted flops for {i}/{len(dataset)} samples")
        flops = high.stop_counters()
        flops = round(flops[0] / (repeat * len(dataset)))
        return flops
Use PYPAPI library to count average flops for model inference.
Note: It only works if the model is being run on cpu
examples/speech_to_speech/benchmarking/core.py