def rerun_marqo_with_env_vars(env_vars: list = [], calling_class: str = ""):
    """
        Given a list of env vars / flags, stop and rerun Marqo using the start script appropriate
        for the current test config

        Ensure that:
        1. Flags are separate items from variable itself (eg, ['-e', 'MARQO_MODELS_TO_PRELOAD=["hf/all_datasets_v4_MiniLM-L6"]'])
        2. Strings (individual items in env_vars list) do not contain ' (use " instead)
        -> single quotes cause some parsing issues and will affect the test outcome
    """

    if calling_class not in ["TestEnvVarChanges", "TestBackendRetries"]:
        raise RuntimeError(
            f"Rerun Marqo function should only be called by `TestEnvVarChanges` to ensure other API tests are not affected. Given calling class is {calling_class}")

    # Stop Marqo
    print("Attempting to stop marqo.")
    subprocess.run(["docker", "stop", "marqo"], check=True, capture_output=True)
    print("Marqo stopped.")

    # Rerun the appropriate start script
    test_config = os.environ["TESTING_CONFIGURATION"]

    if test_config == "CPU_LOCAL_MARQO":
        start_script_name = "start_local_marqo.sh"
    elif test_config == "CPU_DOCKER_MARQO":
        start_script_name = "start_docker_marqo.sh"
    elif test_config == "CUDA_DOCKER_MARQO":
        start_script_name = "start_cuda_docker_marqo.sh"
    else:
        raise RuntimeError(f"Invalid testing configuration: {test_config}. "
                           f"Must be one of ('CPU_LOCAL_MARQO', 'CPU_DOCKER_MARQO', "
                           f"'CUDA_DOCKER_MARQO') to run the application tests."
                           f"If you are using a 'CUSTOM', please only run the tests under 'tests/api_tests'")
    full_script_path = f"{os.environ['MARQO_API_TESTS_ROOT']}/scripts/{start_script_name}"

    run_process = subprocess.Popen(
        [
            "bash",  # command: run
            full_script_path,  # script to run
            os.environ['MARQO_IMAGE_NAME'],  # arg $1 in script
        ] + env_vars,  # args $2 onwards
        stdout=subprocess.PIPE,
        stderr=subprocess.STDOUT,
        universal_newlines=True
    )

    # Read and print the output line by line (in real time)
    for line in run_process.stdout:
        print(line, end='')

    # Wait for the process to complete
    run_process.wait()
    return True

        Given a list of env vars / flags, stop and rerun Marqo using the start script appropriate
        for the current test config

        Ensure that:
        1. Flags are separate items from variable itself (eg, ['-e', 'MARQO_MODELS_TO_PRELOAD=["hf/all_datasets_v4_MiniLM-L6"]'])
        2. Strings (individual items in env_vars list) do not contain ' (use " instead)
        -> single quotes cause some parsing issues and will affect the test outcome
    
tests/api_tests/v1/tests/utilities.py