def METHOD_NAME(self, name_for_dumped_files: Text, tmp_path: Path) -> None:
    # Run as separate process to avoid other things affecting the memory usage.
    # Unfortunately `memory-profiler` doesn't work properly with
    # `multiprocessing.Process` as it can't handle the process exit
    process = subprocess.Popen(
        [
            sys.executable,
            "-c",
            (
                f"from {__name__} import {self.__class__.__name__}; "
                f"t = {self.__class__.__name__}();"
                f"t.function_to_profile()"
            ),
        ],
        # Force TensorFlow to use CPU so we can track the memory usage
        env={"CUDA_VISIBLE_DEVICES": "-1"},
    )
    # Wait until process is running to avoid race conditions with the memory
    # profiling
    while not psutil.pid_exists(process.pid):
        time.sleep(0.01)
    results = memory_profiler.memory_usage(
        process, interval=PROFILING_INTERVAL, include_children=True, timestamps=True
    )
    # `memory-profiler` sometimes adds `None` values at the end which we don't need
    results = [
        memory_timestamp
        for memory_timestamp in results
        if memory_timestamp is not None
    ]
    if WRITE_RESULTS_TO_DISK:
        self._write_results(name_for_dumped_files, results)
    max_memory_usage = max(results, key=lambda memory_time: memory_time[0])[0]
    assert max_memory_usage < self.max_memory_threshold_mb