docstr: Run 'cmd' in a shell then return the (process, stdout) as a tuple
docstr_tok: ["Run","'cmd","'","in","a","shell","then","return","the","(","process",",","stdout",")","as","a","tuple"]
code: def tee(self, cmd: str, **kwargs):
      """
      Run 'cmd' in a shell then return the (process, stdout) as a tuple
      """
  
      logging.info(f"+ {cmd}")
  
      kwargs = {
          **self._default_popen_flags(),
          **kwargs,
          "stdout": subprocess.PIPE,
      }
      proc = subprocess.Popen(cmd, **kwargs)
  
      stdout = []
  
      def _tee_output(s):
          stdout.append(s)
          print(s, end="")
  
      while proc.poll() is None:
          _tee_output(proc.stdout.readline())
      _tee_output(proc.stdout.read())
  
      stdout = "".join(stdout)
      if proc.returncode:
          raise subprocess.CalledProcessError(
              proc.returncode, proc.args, stdout
          )
  
      return proc, stdout
  
file_path: tvm/ci/scripts/jenkins/cmd_utils.py
imports: import subprocess
  import os
  import logging
  import sys
  import re
  import tempfile
  from pathlib import Path
  from typing import List
label_desc: Use image node_id 2 for calling the Sh obj's underlying member method code with example usage: obj.tee(cmd) and returns: proc,  stdout