code: def from_json(cls, json_obj):
      self = cls()
      self.name = json_obj["name"].replace(
          _show_name_pattern.match(json_obj["name"]).group(2), ""
      )
      self.type = json_obj["cat"]
      self.start_ns = int(
          float(json_obj["args"]["start_time"].split(" ")[0]) * 1000
      )
      self.end_ns = int(
          float(json_obj["args"]["end_time"].split(" ")[0]) * 1000
      )
      self.device_id = json_obj["pid"]
      self.stream_id = json_obj["tid"]
      self.context_id = (
          json_obj["args"]["context"]
          if "context" in json_obj["args"]
          else 0
      )
      self.correlation_id = json_obj["args"]["correlation id"]
      self.block_x, self.block_y, self.block_z = (
          json_obj["args"]["block"]
          if "block" in json_obj["args"]
          else [0, 0, 0]
      )
      self.grid_x, self.grid_y, self.grid_z = (
          json_obj["args"]["grid"]
          if "grid" in json_obj["args"]
          else [0, 0, 0]
      )
      self.shared_memory = (
          json_obj["args"]["shared memory"]
          if "shared memory" in json_obj["args"]
          else 0
      )
      self.registers_per_thread = (
          json_obj["args"]["registers per thread"]
          if "registers per thread" in json_obj["args"]
          else 0
      )
      self.num_bytes = (
          json_obj["args"]["bytes"]
          if "bytes" in json_obj["args"]
          else 0
      )
      self.value = (
          json_obj["args"]["value"]
          if "value" in json_obj["args"]
          else 0
      )
      self.occupancy = (
          json_obj["args"]["theoretical achieved occupancy %"]
          if "theoretical achieved occupancy %" in json_obj["args"]
          else 0
      )
      self.blocks_per_sm = (
          json_obj["args"]["blocks per SM"]
          if "blocks per SM" in json_obj["args"]
          else 0
      )
      self.warps_per_sm = (
          json_obj["args"]["warps per SM"]
          if "warps per SM" in json_obj["args"]
          else 0
      )
      return self
  
imports: import collections
  import functools
  import json
  import re
  import sys
  import tempfile
  from .utils import traverse_tree
label_desc: Use image node_id 2 for calling the DeviceNode obj's underlying member method code with example usage: obj.from_json(cls, json_obj) and returns: self