code: def execute_remote(
      cmd: str, ip: str, port: int, username: Optional[str] = ""
  ) -> Thread:
      """Execute command line on remote machine via ssh.
  
      Args:
          cmd: User-defined command (udf) to execute on the remote host.
          ip: The ip-address of the host to run the command on.
          port: Port number that the host is listening on.
          thread_list:
          username: Optional. If given, this will specify a username to use when issuing commands over SSH.
              Useful when your infra requires you to explicitly specify a username to avoid permission issues.
  
      Returns:
          thread: The Thread whose run() is to run the `cmd` on the remote host. Returns when the cmd completes
              on the remote host.
      """
      ip_prefix = ""
      if username:
          ip_prefix += "{username}@".format(username=username)
  
      # Construct ssh command that executes `cmd` on the remote host
      ssh_cmd = "ssh -o StrictHostKeyChecking=no -p {port} {ip_prefix}{ip} '{cmd}'".format(
          port=str(port),
          ip_prefix=ip_prefix,
          ip=ip,
          cmd=cmd,
      )
  
      # thread func to run the job
      def run(ssh_cmd):
          subprocess.check_call(ssh_cmd, shell=True)
  
      thread = Thread(target=run, args=(ssh_cmd,))
      thread.setDaemon(True)
      thread.start()
      return thread
  
imports: import argparse
  import json
  import logging
  import multiprocessing
  import os
  import re
  import signal
  import stat
  import subprocess
  import sys
  import time
  from functools import partial
  from threading import Thread
  from typing import Optional
label_desc: Use image node_id 4 for calling a global function with example usage: execute_remote(cmd, ip, port, username) and returns: thread