code: def test_subprocess_script_launcher_hydra_in_use(
      _, popen_mock, monkeypatch
  ):
      basic_command = Mock(return_value="basic_command")
      hydra_command = Mock(return_value=("hydra_command", "hydra_cwd"))
      monkeypatch.setattr(
          lightning.fabric.strategies.launchers.subprocess_script,
          "_basic_subprocess_cmd",
          basic_command,
      )
      monkeypatch.setattr(
          lightning.fabric.strategies.launchers.subprocess_script,
          "_hydra_subprocess_cmd",
          hydra_command,
      )
  
      def simulate_launch():
          cluster_env = Mock()
          cluster_env.creates_processes_externally = False
          cluster_env.local_rank.return_value = 0
          cluster_env.main_address = "address"
          cluster_env.main_port = 1234
          function = Mock()
          launcher = _SubprocessScriptLauncher(
              cluster_env, num_processes=4, num_nodes=2
          )
          launcher.launch(function)
  
      # when hydra not available
      monkeypatch.setattr(
          lightning.fabric.strategies.launchers.subprocess_script,
          "_HYDRA_AVAILABLE",
          False,
      )
      simulate_launch()
      popen_mock.assert_called_with("basic_command", env=ANY, cwd=None)
      popen_mock.reset_mock()
  
      import hydra
  
      # when hydra available but not initialized
      monkeypatch.setattr(
          lightning.fabric.strategies.launchers.subprocess_script,
          "_HYDRA_AVAILABLE",
          True,
      )
      HydraConfigMock = Mock()
      HydraConfigMock.initialized.return_value = False
      monkeypatch.setattr(
          hydra.core.hydra_config, "HydraConfig", HydraConfigMock
      )
      simulate_launch()
      popen_mock.assert_called_with("basic_command", env=ANY, cwd=None)
      popen_mock.reset_mock()
  
      # when hydra available and initialized
      monkeypatch.setattr(
          lightning.fabric.strategies.launchers.subprocess_script,
          "_HYDRA_AVAILABLE",
          True,
      )
      HydraConfigMock = Mock()
      HydraConfigMock.initialized.return_value = True
      monkeypatch.setattr(
          hydra.core.hydra_config, "HydraConfig", HydraConfigMock
      )
      simulate_launch()
      popen_mock.assert_called_with(
          "hydra_command", env=ANY, cwd="hydra_cwd"
      )
      popen_mock.reset_mock()
  
file_path: pytorch-lightning/tests/tests_fabric/strategies/launchers/test_subprocess_script.py
imports: import os
  import signal
  import sys
  from unittest import mock
  from unittest.mock import ANY, Mock
  import lightning.fabric
  import pytest
  from lightning.fabric.strategies.launchers.subprocess_script import _HYDRA_AVAILABLE, _ChildProcessObserver, _SubprocessScriptLauncher
label_desc: Use image node_id 5 for calling a global function with example usage: test_subprocess_script_launcher_hydra_in_use(_, popen_mock, monkeypatch) without return types