def METHOD_NAME(self, line: str, cell: str) -> None:
    """Memory profile the code in the cell and display a flame graph."""
    if self.shell is None:
        raise UsageError("Cannot profile code when not in a shell")
    try:
        options = argument_parser().parse_args(shlex.split(line))
    except SystemExit:
        # argparse wants to bail if the options aren't valid.
        # It already printed a message, just return control to IPython.
        return
    results_dir = Path("memray-results")
    results_dir.mkdir(exist_ok=True)
    tempdir = Path(tempfile.mkdtemp(dir=results_dir))
    dump_file = Path(tempdir) / "memray.dump"
    code = TEMPLATE.format(
        dump_file=dump_file,
        native_traces=options.native,
        trace_python_allocators=options.trace_python_allocators,
        follow_fork=options.follow_fork,
        code=indent(cell, " " * 4),
    )
    self.shell.run_cell(code)
    merge_threads = not options.split_threads
    reporter = None
    with FileReader(dump_file, report_progress=True) as reader:
        if reader.metadata.has_native_traces:
            warn_if_not_enough_symbols()
        if options.show_memory_leaks:
            snapshot = reader.get_leaked_allocation_records(
                merge_threads=merge_threads
            )
        elif options.temporary_allocation_threshold >= 0:
            snapshot = reader.get_temporary_allocation_records(
                threshold=options.temporary_allocation_threshold,
                merge_threads=merge_threads,
            )
        else:
            snapshot = reader.get_high_watermark_allocation_records(
                merge_threads=merge_threads
            )
        memory_records = tuple(reader.get_memory_snapshots())
        reporter = FlameGraphReporter.from_snapshot(
            snapshot,
            memory_records=memory_records,
            native_traces=options.native,
            inverted=options.inverted,
        )
    assert reporter is not None
    flamegraph_path = Path(tempdir) / "flamegraph.html"
    with open(flamegraph_path, "w") as f:
        reporter.render(
            outfile=f,
            metadata=reader.metadata,
            show_memory_leaks=options.show_memory_leaks,
            merge_threads=merge_threads,
            inverted=options.inverted,
        )
    dump_file.unlink()
    pprint(f"Results saved to [bold cyan]{flamegraph_path}")
    display(IFrame(flamegraph_path, width="100%", height="600"))  # type: ignore