code: def test_profiler_experimental_tree_cuda(self):
      with torch.profiler.profile(profile_memory=True) as p:
          weight = torch.ones(1, device="cuda", requires_grad=True)
          x = torch.ones(1, device="cuda")
          y = torch.add(weight, x)
          loss = torch.pow(y, 2)
          loss.backward()
          torch.optim.SGD([weight], lr=0.01, momentum=0.9).step()
  
      self.assertTreesMatch(
          ProfilerTree.format(p.profiler, 12),
          """\
              aten::ones
                aten::empty
                  [memory]
                aten::fill_
                  cudaLaunchKernel
                    void at::native::vectorized_elementwise_kernel<...>(...)
              aten::ones
                aten::empty
                  [memory]
                aten::fill_
                  cudaLaunchKernel
                    void at::native::vectorized_elementwise_kernel<...>(...)
              aten::add
                cudaLaunchKernel
                  void at::native::vectorized_elementwise_kernel<...>(...)
                [memory]
              aten::pow
                cudaLaunchKernel
                  void at::native::vectorized_elementwise_kernel<...>(...)
                aten::result_type
                aten::to
                [memory]
              aten::ones_like
                aten::empty_like
                  aten::empty_strided
                    [memory]
                aten::fill_
                  cudaLaunchKernel
                    void at::native::vectorized_elementwise_kernel<...>(...)
              autograd::engine::evaluate_function: PowBackward0
                PowBackward0
                  aten::pow
                    aten::result_type
                    aten::to
                    [memory]
                    aten::copy_
                      cudaMemcpyAsync
                        Memcpy DtoD (Device -> Device)
                  aten::mul
                    [memory]
                    aten::mul
                      cudaLaunchKernel
                        void at::native::vectorized_elementwise_kernel<...>(...)
                      [memory]
                    [memory]
                  aten::mul
                    cudaLaunchKernel
                      void at::native::vectorized_elementwise_kernel<...>(...)
                    [memory]
                  [memory]
                  [memory]
              autograd::engine::evaluate_function: AddBackward0
                AddBackward0
              autograd::engine::evaluate_function: torch::autograd::AccumulateGrad
                torch::autograd::AccumulateGrad
                  aten::detach
                    detach
              [memory]
              aten::zeros
                aten::zeros
                  aten::empty
                    [memory]
                  aten::zero_
              Optimizer.step#SGD.step
                aten::empty
                  [memory]
                [memory]
                [memory]
                aten::clone
                  aten::empty_strided
                    [memory]
                  aten::copy_
                    cudaMemcpyAsync
                      Memcpy DtoD (Device -> Device)
                aten::detach
                  detach
                aten::add_
                  cudaLaunchKernel
                    void at::native::vectorized_elementwise_kernel<...>(...)
              [memory]""",  # noqa: B950
          allow_failure=ALLOW_CUDA_FAILURE,
      )
  
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 9 for calling the TestProfilerTree obj's underlying member method code with example usage: obj.test_profiler_experimental_tree_cuda() without return types