code: def patch_mongo_client(monkeypatch, db_type):
      """Patch ``pymongo.MongoClient`` to force serverSelectionTimeoutMS to 1."""
      if db_type != "mongodb":
          pytest.skip("mongodb test only")
  
      def mock_class(*args, **kwargs):
          # 1 sec, defaults to 20 secs otherwise
          kwargs["serverSelectionTimeoutMS"] = 1.0
          # NOTE: Can't use pymongo.MongoClient otherwise there is an infinite
          # recursion; mock(mock(mock(mock(...(MongoClient)...))))
          return MongoClient(*args, **kwargs)
  
      monkeypatch.setattr("pymongo.MongoClient", mock_class)
  
imports: import functools
  from timeit import timeit
  import pymongo
  import pytest
  from pymongo import MongoClient
  from orion.core.io.database import Database, DatabaseError, DuplicateKeyError
  from orion.core.io.database.mongodb import AUTH_FAILED_MESSAGES, MongoDB
  from .conftest import insert_test_collection
  from .test_database import get_db
label_desc: Use image node_id 2 for calling a global function with example usage: patch_mongo_client(monkeypatch, db_type) and returns: MongoClient