code: def print_formatted(
      self,
      fp=sys.stdout,
      *,
      force_color=False,
      no_color=False,
      show_cmd=False,
      show_full_cmd=False,
      show_user=False,
      show_pid=False,
      show_fan_speed=None,
      show_codec="",
      show_power=None,
      gpuname_width=None,
      show_header=True,
      no_processes=False,
      eol_char=os.linesep,
  ):
      # ANSI color configuration
      if force_color and no_color:
          raise ValueError(
              "--color and --no_color can't" " be used at the same time"
          )
  
      if force_color:
          TERM = os.getenv("TERM") or "xterm-256color"
          t_color = Terminal(kind=TERM, force_styling=True)
  
          # workaround of issue #32 (watch doesn't recognize sgr0 characters)
          # pylint: disable-next=protected-access
          t_color._normal = "\x1b[0;10m"  # type: ignore
      elif no_color:
          t_color = Terminal(force_styling=None)  # type: ignore
      else:
          t_color = Terminal()  # auto, depending on isatty
  
      # appearance settings
      if gpuname_width is None:
          gpuname_width = max(
              [len(g.entry["name"]) for g in self] + [0]
          )
  
      # header
      if show_header:
          if IS_WINDOWS:
              # no localization is available; just use a reasonable default
              # same as str(timestr) but without ms
              timestr = self.query_time.strftime("%Y-%m-%d %H:%M:%S")
          else:
              time_format = locale.nl_langinfo(locale.D_T_FMT)
              timestr = self.query_time.strftime(time_format)
          header_template = (
              "{t.bold_white}{hostname:{width}}{t.normal}  "
          )
          header_template += "{timestr}  "
          header_template += "{t.bold_black}{driver_version}{t.normal}"
  
          header_msg = header_template.format(
              hostname=self.hostname,
              width=(gpuname_width or DEFAULT_GPUNAME_WIDTH)
              + 3,  # len("[?]")
              timestr=timestr,
              driver_version=self.driver_version,
              t=t_color,
          )
  
          fp.write(header_msg.strip())
          fp.write(eol_char)
  
      # body
      for g in self:
          g.print_to(
              fp,
              show_cmd=show_cmd,
              show_full_cmd=show_full_cmd,
              no_processes=no_processes,
              show_user=show_user,
              show_pid=show_pid,
              show_fan_speed=show_fan_speed,
              show_codec=show_codec,
              show_power=show_power,
              gpuname_width=gpuname_width,
              eol_char=eol_char,
              term=t_color,
          )
          fp.write(eol_char)
  
      if len(self.gpus) == 0:
          print(t_color.yellow("(No GPUs are available)"))
  
      fp.flush()
  
imports: import functools
  from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, List, Optional, Sequence, Union, cast
  import json
  import locale
  import os.path
  import platform
  import sys
  import time
  from datetime import datetime
  from io import StringIO
  import psutil
  from blessed import Terminal
  from gpustat import util
  from gpustat import nvml
  from gpustat.nvml import pynvml
  from gpustat.nvml import check_driver_nvml_version
label_desc: Use image node_id 8 for calling the GPUStatCollection obj's underlying member method code with example usage: obj.print_formatted(fp) without return types