class_docstr: Collect and plot the memory stats at operator level.
  
  Includes ``memories_allocated``, ``memories_active`` and ``memories_reserved``.
  It also prints a summary for the top 20 operators that generate the most memories.
  
  Example usage:
  
      >>> # xdoctest: +SKIP(failing)
      >>> net.cuda()
      >>> input = input.cuda()
  
      >>> mem_tracker = MemoryTracker()
      >>> mem_tracker.start_monitor(net)
  
      >>> net.zero_grad(True)
      >>> loss = net(input)
      >>> if isinstance(loss, dict):
      >>>    loss = loss['out']
      >>> loss.sum().backward()
      >>> net.zero_grad(set_to_none=True)
  
      >>> mem_tracker.stop()
      >>> mem_tracker.summary()
      >>> mem_tracker.show_traces()
class_docstr_tok: ["Collect","and","plot","the","memory","stats","at","operator","level",".","Includes","``","memories_allocated","``",",","``","memories_active","``","and","``","memories_reserved","``",".","It","also","prints","a","summary","for","the","top","20","operators","that","generate","the","most","memories",".","Example","usage",":",">",">",">","#","xdoctest",":","+SKIP","(","failing",")",">",">",">","net.cuda","(",")",">",">",">","input","=","input.cuda","(",")",">",">",">","mem_tracker","=","MemoryTracker","(",")",">",">",">","mem_tracker.start_monitor","(","net",")",">",">",">","net.zero_grad","(","True",")",">",">",">","loss","=","net","(","input",")",">",">",">","if","isinstance","(","loss",",","dict",")",":",">",">",">","loss","=","loss","[","'out","'","]",">",">",">","loss.sum","(",")",".backward","(",")",">",">",">","net.zero_grad","(","set_to_none=True",")",">",">",">","mem_tracker.stop","(",")",">",">",">","mem_tracker.summary","(",")",">",">",">","mem_tracker.show_traces","(",")"]
docstr: Load the pickled memory stats to plot the traces or print the summary.
docstr_tok: ["Load","the","pickled","memory","stats","to","plot","the","traces","or","print","the","summary","."]
code: def load(self, path: str) -> None:
      """Load the pickled memory stats to plot the traces or print the summary."""
      with open(path, "rb") as f:
          stats = pickle.load(f)
  
      self.memories_allocated = stats["memories_allocated"]
      self.memories_active = stats["memories_active"]
      self.memories_reserved = stats["memories_reserved"]
      self._markers = stats["markers"]
      self._num_cuda_retries = stats["num_alloc_retries"]
  
imports: from collections import defaultdict
  from itertools import chain
  import pickle
  from typing import Any, Callable, Dict, List, no_type_check, Sequence
  import torch
  import torch.nn
  from torch.utils.hooks import RemovableHandle
  from torch.utils._python_dispatch import TorchDispatchMode
label_desc: Use image node_id 7 for calling the MemoryTracker obj's underlying member method code with example usage: obj.load(path) without return types