code: def test_rolling_apply_mutability(self):
      # GH 14013
      df = DataFrame({"A": ["foo"] * 3 + ["bar"] * 3, "B": [1] * 6})
      g = df.groupby("A")
  
      mi = MultiIndex.from_tuples(
          [
              ("bar", 3),
              ("bar", 4),
              ("bar", 5),
              ("foo", 0),
              ("foo", 1),
              ("foo", 2),
          ]
      )
  
      mi.names = ["A", None]
      # Grouped column should not be a part of the output
      expected = DataFrame(
          [np.nan, 2.0, 2.0] * 2, columns=["B"], index=mi
      )
  
      result = g.rolling(window=2).sum()
      tm.assert_frame_equal(result, expected)
  
      # Call an arbitrary function on the groupby
      g.sum()
  
      # Make sure nothing has been mutated
      result = g.rolling(window=2).sum()
      tm.assert_frame_equal(result, expected)
  
imports: import numpy
  import pytest
  from pandas import DataFrame, DatetimeIndex, Index, MultiIndex, Series, Timestamp, date_range, to_datetime
  import pandas._testing
  from pandas.api.indexers import BaseIndexer
  from pandas.core.groupby.groupby import get_groupby
label_desc: Use image node_id 12 for calling the TestRolling obj's underlying member method code with example usage: obj.test_rolling_apply_mutability() without return types