code: def check_output_command(file_path, head=None, tail=None):
      """call check_output command to read content from a file"""
      if os.path.exists(file_path):
          if sys.platform == "win32":
              cmds = ["powershell.exe", "type", file_path]
              if head:
                  cmds += ["|", "select", "-first", str(head)]
              elif tail:
                  cmds += ["|", "select", "-last", str(tail)]
              return check_output(cmds, shell=True).decode("utf-8")
          else:
              cmds = ["cat", file_path]
              if head:
                  cmds = ["head", "-" + str(head), file_path]
              elif tail:
                  cmds = ["tail", "-" + str(tail), file_path]
              return check_output(cmds, shell=False).decode("utf-8")
      else:
          print_error("{0} does not exist!".format(file_path))
          exit(1)
  
file_path: nni/nni/tools/nnictl/command_utils.py
imports: from subprocess import call, check_output
  import sys
  import os
  import time
  import signal
  import psutil
  from .common_utils import print_error, print_warning
label_desc: Use image node_id 1 for calling a global function with example usage: check_output_command(file_path, head, tail) and returns: check_output, check_output