code: def patch_gcloud(monkeypatch, gcloud_run, gcloud_config):
      """Automatically replace gcloud functions with mocks."""
      monkeypatch.setattr(
          "hailtop.hailctl.dataproc.gcloud.run", gcloud_run
      )
      monkeypatch.setattr(
          "hailtop.hailctl.dataproc.gcloud.get_version",
          Mock(return_value=MINIMUM_REQUIRED_GCLOUD_VERSION),
      )
  
      def mock_gcloud_get_config(setting):
          return gcloud_config.get(setting, None)
  
      monkeypatch.setattr(
          "hailtop.hailctl.dataproc.gcloud.get_config",
          mock_gcloud_get_config,
      )
  
      yield
  
      monkeypatch.undo()
  
imports: from unittest.mock import Mock
  import pytest
  from hailtop.hailctl.dataproc.cli import MINIMUM_REQUIRED_GCLOUD_VERSION
label_desc: Use image node_id 3 for calling a global function with example usage: patch_gcloud(monkeypatch, gcloud_run, gcloud_config) and returns: gcloud_config