code: def test__safe_set_output():
      """Check _safe_set_output works as expected."""
  
      # Estimator without transform will not raise when setting set_output for transform.
      est = EstimatorWithoutSetOutputAndWithoutTransform()
      _safe_set_output(est, transform="pandas")
  
      # Estimator with transform but without set_output will raise
      est = EstimatorNoSetOutputWithTransform()
      with pytest.raises(
          ValueError, match="Unable to configure output"
      ):
          _safe_set_output(est, transform="pandas")
  
      est = EstimatorWithSetOutput().fit(np.asarray([[1, 2, 3]]))
      _safe_set_output(est, transform="pandas")
      config = _get_output_config("transform", est)
      assert config["dense"] == "pandas"
  
      _safe_set_output(est, transform="default")
      config = _get_output_config("transform", est)
      assert config["dense"] == "default"
  
      # transform is None is a no-op, so the config remains "default"
      _safe_set_output(est, transform=None)
      config = _get_output_config("transform", est)
      assert config["dense"] == "default"
  
imports: import importlib
  from collections import namedtuple
  import numpy
  import pytest
  from numpy.testing import assert_array_equal
  from sklearn._config import config_context, get_config
  from sklearn.preprocessing import StandardScaler
  from sklearn.utils._set_output import ADAPTERS_MANAGER, ContainerAdapterProtocol, _get_output_config, _safe_set_output, _SetOutputMixin, _wrap_data_with_container, check_library_installed
  from sklearn.utils.fixes import CSR_CONTAINERS
label_desc: Use image node_id 4 for calling a global function with example usage: test__safe_set_output() without return types