code: def test_memory_profiler_command_builder(monkeypatch, tmp_path):
      session_dir = tmp_path
      # When there's no env var, command should be just a regular python command.
      command = (
          services._build_python_executable_command_memory_profileable(
              ray_constants.PROCESS_TYPE_DASHBOARD, session_dir
          )
      )
      assert command == [sys.executable, "-u"]
  
      with monkeypatch.context() as m:
          m.setenv(
              services.RAY_MEMRAY_PROFILE_COMPONENT_ENV, "dashboard"
          )
          m.setenv(services.RAY_MEMRAY_PROFILE_OPTIONS_ENV, "-q")
          command = services._build_python_executable_command_memory_profileable(
              ray_constants.PROCESS_TYPE_DASHBOARD, session_dir
          )
  
          assert command == [
              sys.executable,
              "-u",
              "-m",
              "memray",
              "run",
              "-o",
              str(
                  Path(tmp_path)
                  / "profile"
                  / f"{Path(tmp_path).name}_memory_dashboard.bin"
              ),  # noqa
              "-q",
          ]
          m.delenv(services.RAY_MEMRAY_PROFILE_COMPONENT_ENV)
          m.delenv(services.RAY_MEMRAY_PROFILE_OPTIONS_ENV)
          m.setenv(
              services.RAY_MEMRAY_PROFILE_COMPONENT_ENV,
              "dashboard,dashboard_agent",
          )
          m.setenv(
              services.RAY_MEMRAY_PROFILE_OPTIONS_ENV,
              "-q,--live,--live-port,1234",
          )
          command = services._build_python_executable_command_memory_profileable(
              ray_constants.PROCESS_TYPE_DASHBOARD_AGENT, session_dir
          )
          assert command == [
              sys.executable,
              "-u",
              "-m",
              "memray",
              "run",
              "-o",
              str(
                  Path(tmp_path)
                  / "profile"
                  / f"{Path(tmp_path).name}_memory_dashboard_agent.bin"
              ),  # noqa
              "-q",
              "--live",
              "--live-port",
              "1234",
          ]
  
file_path: ray/python/ray/tests/test_debug_tools.py
imports: import os
  import subprocess
  import sys
  import pytest
  from pathlib import Path
  import ray
  import ray._private.services
  import ray._private.ray_constants
  from ray._private.test_utils import wait_for_condition
label_desc: Use image node_id 3 for calling a global function with example usage: test_memory_profiler_command_builder(monkeypatch, tmp_path) without return types