def max_memory(self, dataset, repeat):
        """Compute average max memory consumed by model inference. Units are MiB"""
        logger.info("Starting memory benchmarking")
        total_memory = 0
        for i, sample in enumerate(dataset):
            for _r in range(repeat):
                total_memory += max(memory_usage((self.forward, (sample,), {})))
            if i % 100 == 0:
                logger.info(f"Benchmarked memory for {i}/{len(dataset)} samples")
        total_memory = total_memory / (repeat * len(dataset))
        return total_memory
Compute average max memory consumed by model inference. Units are MiB
understand_icl/fairseq/examples/speech_to_speech/benchmarking/core.py