code: def test_replace_compiled_regex_raises(any_string_dtype):
      # case and flags provided to str.replace will have no effect
      # and will produce warnings
      ser = Series(
          ["fooBAD__barBAD__bad", np.nan], dtype=any_string_dtype
      )
      pat = re.compile(r"BAD_*")
  
      msg = "case and flags cannot be set when pat is a compiled regex"
  
      with pytest.raises(ValueError, match=msg):
          ser.str.replace(pat, "", flags=re.IGNORECASE, regex=True)
  
      with pytest.raises(ValueError, match=msg):
          ser.str.replace(pat, "", case=False, regex=True)
  
      with pytest.raises(ValueError, match=msg):
          ser.str.replace(pat, "", case=True, regex=True)
  
imports: from datetime import datetime
  import re
  import numpy
  import pytest
  from pandas.errors import PerformanceWarning
  import pandas.util._test_decorators
  import pandas
  from pandas import Series, _testing
  from pandas.tests.strings import _convert_na_value, object_pyarrow_numpy
label_desc: Use image node_id 23 for calling a global function with example usage: test_replace_compiled_regex_raises(any_string_dtype) without return types