code: def wrap_cmd_with_local_envvars(cmd: str, env_vars: str) -> str:
      """Wraps a CLI command with desired env vars with the following properties:
      (1) env vars persist for the entire `cmd`, even if it consists of multiple "chained" commands like:
          cmd = "ls && pwd && python run/something.py"
      (2) env vars don't pollute the environment after `cmd` completes.
  
      Example:
          >>> cmd = "ls && pwd"
          >>> env_vars = "VAR1=value1 VAR2=value2"
          >>> wrap_cmd_with_local_envvars(cmd, env_vars)
          "(export VAR1=value1 VAR2=value2; ls && pwd)"
  
      Args:
          cmd:
          env_vars: A string containing env vars, eg "VAR1=val1 VAR2=val2"
  
      Returns:
          cmd_with_env_vars:
  
      """
      # use `export` to persist env vars for entire cmd block. required if udf_command is a chain of commands
      # also: wrap in parens to not pollute env:
      #     https://stackoverflow.com/a/45993803
      return f"(export {env_vars}; {cmd})"
  
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 10 for calling a global function with example usage: wrap_cmd_with_local_envvars(cmd, env_vars) and returns: str, env_vars, str, cmd, str