code: def get_gpu_memory_from_nvidia_smi(  # pragma: no cover
      device: int = 0,
      digits: int = 2,
  ) -> Tuple[float, float]:
      r"""Returns the free and used GPU memory in megabytes, as reported by
      :obj:`nivdia-smi`.
  
      .. note::
  
          :obj:`nvidia-smi` will generally overestimate the amount of memory used
          by the actual program, see `here <https://pytorch.org/docs/stable/
          notes/faq.html#my-gpu-memory-isn-t-freed-properly>`__.
  
      Args:
          device (int, optional): The GPU device identifier. (default: :obj:`1`)
          digits (int): The number of decimals to use for megabytes.
              (default: :obj:`2`)
      """
      CMD = "nvidia-smi --query-gpu=memory.free --format=csv"
      free_out = (
          sp.check_output(CMD.split()).decode("utf-8").split("\n")[1:-1]
      )
  
      CMD = "nvidia-smi --query-gpu=memory.used --format=csv"
      used_out = (
          sp.check_output(CMD.split()).decode("utf-8").split("\n")[1:-1]
      )
  
      if device < 0 or device >= len(free_out):
          raise AttributeError(
              f"GPU {device} not available (found {len(free_out)} GPUs)"
          )
  
      free_mem = medibyte_to_megabyte(
          int(free_out[device].split()[0]), digits
      )
      used_mem = medibyte_to_megabyte(
          int(used_out[device].split()[0]), digits
      )
  
      return free_mem, used_mem
  
imports: import gc
  import os
  import os.path
  import random
  import subprocess
  import sys
  import warnings
  from collections.abc import Mapping, Sequence
  from typing import Any, Tuple
  import torch
  from torch import Tensor
  from torch_geometric.data.data import BaseData
  from torch_geometric.typing import SparseTensor
label_desc: Use image node_id 6 for calling a global function with example usage: get_gpu_memory_from_nvidia_smi(device, digits) and returns: free_mem,  used_mem