code: def prevent_infer_pip_requirements_fallback(request):
      """
      Prevents `mlflow.models.infer_pip_requirements` from falling back in `mlflow.*.save_model`
      unless explicitly disabled via `pytest.mark.allow_infer_pip_requirements_fallback`.
      """
      from mlflow.utils.environment import (
          _INFER_PIP_REQUIREMENTS_FALLBACK_MESSAGE,
      )
  
      def new_exception(msg, *_, **__):
          if (
              msg == _INFER_PIP_REQUIREMENTS_FALLBACK_MESSAGE
              and _called_in_save_model()
          ):
              raise Exception(
                  "`mlflow.models.infer_pip_requirements` should not fall back in"
                  "`mlflow.*.save_model` during test"
              )
  
      if (
          "allow_infer_pip_requirements_fallback"
          not in request.keywords
      ):
          with mock.patch(
              "mlflow.utils.environment._logger.exception",
              new=new_exception,
          ):
              yield
      else:
          yield
  
imports: import inspect
  import os
  import shutil
  import subprocess
  from unittest import mock
  import pytest
  import mlflow
  from mlflow.tracking._tracking_service.utils import _use_tracking_uri
  from mlflow.utils.file_utils import path_to_local_sqlite_uri
  from mlflow.utils.os import is_windows
  from tests.autologging.fixtures import enable_test_mode
label_desc: Use image node_id 6 for calling a global function with example usage: prevent_infer_pip_requirements_fallback(request) without return types