code: def test_profiler_experimental_tree_with_memory(self):
      t1, t2 = torch.ones(1, requires_grad=True), torch.ones(
          1, requires_grad=True
      )
      with torch.profiler.profile(profile_memory=True) as p:
          z = torch.add(t1, t2)
          y = torch.ones(1)
          loss = (y - z) ** 2
          loss.backward()
  
      self.assertTreesMatch(
          ProfilerTree.format(p.profiler, 12),
          """\
              aten::add
                [memory]
              aten::ones
                aten::empty
                  [memory]
                aten::fill_
              aten::sub
                [memory]
              aten::pow
                aten::result_type
                aten::to
                [memory]
              aten::ones_like
                aten::empty_like
                  aten::empty_strided
                    [memory]
                aten::fill_
              autograd::engine::evaluate_function: PowBackward0
                PowBackward0
                  aten::pow
                    aten::result_type
                    aten::to
                    [memory]
                    aten::copy_
                  aten::mul
                    [memory]
                    aten::mul
                      aten::to
                        aten::_to_copy
                          aten::empty_strided
                            [memory]
                          aten::copy_
                      [memory]
                      [memory]
                    [memory]
                  aten::mul
                    [memory]
                  [memory]
                  [memory]
                [memory]
              autograd::engine::evaluate_function: SubBackward0
                SubBackward0
                  aten::neg
                    [memory]
                [memory]
              autograd::engine::evaluate_function: AddBackward0
                AddBackward0
              autograd::engine::evaluate_function: torch::autograd::AccumulateGrad
                torch::autograd::AccumulateGrad
                  aten::new_empty_strided
                    aten::empty_strided
                      [memory]
                  aten::copy_
              autograd::engine::evaluate_function: torch::autograd::AccumulateGrad
                torch::autograd::AccumulateGrad
                  aten::detach
                    detach
              [memory]""",
      )
  
imports: import functools
  import os
  import re
  import textwrap
  import traceback
  import unittest
  import expecttest
  import torch
  from torch._C._profiler import _ExtraFields_PyCall, _ExtraFields_PyCCall
  from torch.testing._internal.common_utils import TestCase, run_tests, IS_WINDOWS, TEST_WITH_CROSSREF, IS_ARM64, skipIfTorchDynamo
  from torch.utils._pytree import tree_map
label_desc: Use image node_id 4 for calling the TestProfilerTree obj's underlying member method code with example usage: obj.test_profiler_experimental_tree_with_memory() without return types