code: def get_available_vram():
      if shared.device.type == "cuda":
          stats = torch.cuda.memory_stats(shared.device)
          mem_active = stats["active_bytes.all.current"]
          mem_reserved = stats["reserved_bytes.all.current"]
          mem_free_cuda, _ = torch.cuda.mem_get_info(
              torch.cuda.current_device()
          )
          mem_free_torch = mem_reserved - mem_active
          mem_free_total = mem_free_cuda + mem_free_torch
          return mem_free_total
      else:
          return psutil.virtual_memory().available
  
imports: from __future__ import annotations
  import math
  import psutil
  import platform
  import torch
  from torch import einsum
  from ldm.util import default
  from einops import rearrange
  from modules import shared, errors, devices, sub_quadratic_attention
  from modules.hypernetworks import hypernetwork
  import ldm.modules.attention
  import ldm.modules.diffusionmodules.model
  import sgm.modules.attention
  import sgm.modules.diffusionmodules.model
label_desc: Use image node_id 2 for calling a global function with example usage: get_available_vram() and returns: mem_free_total, psutil