code: def __exit__(self, *exc):
      self.peak_monitoring = False
  
      gc.collect()
      if is_xpu_available():
          torch.xpu.empty_cache()
          self.end = byte2gb(torch.xpu.memory_allocated())
          self.peak = byte2gb(torch.xpu.max_memory_allocated())
          xpu_info = torch.xpu.memory_stats()
          self.peak_active_gb = byte2gb(
              xpu_info["active_bytes.all.peak"]
          )
          self.xpu_malloc_retires = xpu_info.get("num_alloc_retries", 0)
          self.peak_active_gb = byte2gb(
              xpu_info["active_bytes.all.peak"]
          )
          self.m_xpu_ooms = xpu_info.get("num_ooms", 0)
          self.used = byte2gb(self.end - self.begin)
          self.peaked = byte2gb(self.peak - self.begin)
          self.max_reserved = byte2gb(torch.xpu.max_memory_reserved())
      else:
          torch.cuda.empty_cache()
          self.end = byte2gb(torch.cuda.memory_allocated())
          self.peak = byte2gb(torch.cuda.max_memory_allocated())
          cuda_info = torch.cuda.memory_stats()
          self.peak_active_gb = byte2gb(
              cuda_info["active_bytes.all.peak"]
          )
          self.cuda_malloc_retires = cuda_info.get(
              "num_alloc_retries", 0
          )
          self.peak_active_gb = byte2gb(
              cuda_info["active_bytes.all.peak"]
          )
          self.m_cuda_ooms = cuda_info.get("num_ooms", 0)
          self.used = byte2gb(self.end - self.begin)
          self.peaked = byte2gb(self.peak - self.begin)
          self.max_reserved = byte2gb(torch.cuda.max_memory_reserved())
  
      self.cpu_end = self.cpu_mem_used()
      self.cpu_used = byte2gb(self.cpu_end - self.cpu_begin)
      self.cpu_peaked = byte2gb(self.cpu_peak - self.cpu_begin)
  
file_path: llama-recipes/utils/memory_utils.py
imports: import gc
  import os
  import sys
  import threading
  import numpy
  import psutil
  import torch
  from accelerate.utils import is_xpu_available
label_desc: Use image node_id 4 for calling the MemoryTrace obj's underlying member method code with example usage: obj.__exit__() without return types