code: def test_profile(self):
      profiler.start(options={"host_tracer_level": 2})
      with trace.Trace("three_times_five"):
          three = constant_op.constant(3)
          five = constant_op.constant(5)
          product = three * five
      self.assertAllEqual(15, product)
      with self.assertRaises(profiler.ProfilerAlreadyRunningError):
          profiler.start()
  
      profile_result = profiler.stop()
      profile_pb = trace_events_pb2.Trace()
      profile_pb.ParseFromString(profile_result)
      devices = frozenset(
          device.name for device in profile_pb.devices.values()
      )
      self.assertIn("/host:CPU", devices)
      if config.list_physical_devices("GPU"):
          self.assertIn("/device:GPU:0", devices)
      events = frozenset(
          event.name for event in profile_pb.trace_events
      )
      self.assertIn("three_times_five", events)
      self.assertIn("Mul", events)
      with self.assertRaises(profiler.ProfilerNotRunningError):
          profiler.stop()
  
file_path: tensorflow-upstream/tensorflow/python/eager/profiler_test.py
imports: import os
  from tensorflow.python.eager import profiler
  from tensorflow.python.eager import test
  from tensorflow.python.framework import config
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import test_util
  from tensorflow.python.platform import gfile
  from tensorflow.python.profiler import trace
  from tsl.profiler.protobuf import trace_events_pb2
label_desc: Use image node_id 1 for calling the ProfilerTest obj's underlying member method code with example usage: obj.test_profile() without return types