code: def test_replace_categorical_inplace_reference(
      using_copy_on_write, val, to_replace
  ):
      df = DataFrame({"a": Categorical([1, 2, 3])})
      df_orig = df.copy()
      arr_a = get_array(df, "a")
      view = df[:]
      msg = (
          r"The behavior of Series\.replace \(and DataFrame.replace\) "
          "with CategoricalDtype"
      )
      warn = FutureWarning if val == 1.5 else None
      with tm.assert_produces_warning(warn, match=msg):
          df.replace(to_replace=to_replace, value=val, inplace=True)
  
      if using_copy_on_write:
          assert not np.shares_memory(
              get_array(df, "a").codes, arr_a.codes
          )
          assert df._mgr._has_no_reference(0)
          assert view._mgr._has_no_reference(0)
          tm.assert_frame_equal(view, df_orig)
      else:
          assert np.shares_memory(get_array(df, "a").codes, arr_a.codes)
  
imports: import numpy
  import pytest
  from pandas import Categorical, DataFrame, option_context
  import pandas._testing
  from pandas.tests.copy_view.util import get_array
label_desc: Use image node_id 13 for calling a global function with example usage: test_replace_categorical_inplace_reference(using_copy_on_write, val, to_replace) without return types