code: def loop_gpustat(interval=1.0, **kwargs):
      term = Terminal()
  
      with term.fullscreen():
          while 1:
              try:
                  query_start = time.time()
  
                  # Move cursor to (0, 0) but do not restore original cursor loc
                  print(term.move(0, 0), end="")
                  print_gpustat(
                      eol_char=term.clear_eol + os.linesep, **kwargs
                  )
                  print(term.clear_eos, end="")
  
                  query_duration = time.time() - query_start
                  sleep_duration = interval - query_duration
                  if sleep_duration > 0:
                      time.sleep(sleep_duration)
              except KeyboardInterrupt:
                  return 0
  
file_path: gpustat/gpustat/cli.py
imports: import os
  import sys
  import time
  from contextlib import suppress
  from blessed import Terminal
  from gpustat import __version__
  from gpustat.core import GPUStatCollection
label_desc: Use image node_id 4 for calling a global function with example usage: loop_gpustat(interval) and returns: int