code: def test_shared_mutable(self):
      bval = np.arange(5)
      b = shared(bval)
      b_out = b * 2
  
      # shared vars copy args.
      assert b.get_value(borrow=True) is not bval
      # so we do this to get at the underlying data
      bval = data_of(b)
  
      # by default, shared are not mutable unless doing an explicit update
      f = pfunc([], [b_out], mode="FAST_RUN")
      assert (f() == np.arange(5) * 2).all()
      assert np.all(b.get_value(borrow=True) == np.arange(5))
  
      # using updates, b is now a mutable parameter
      f = pfunc([], [b_out], updates=[(b, b_out)], mode="FAST_RUN")
      assert (f() == (np.arange(5) * 2)).all()
      # because of the update
      assert (b.get_value(borrow=True) == (np.arange(5) * 2)).all()
      assert (
          bval == (np.arange(5) * 2)
      ).all()  # because of mutable=True
  
      # do not depend on updates being in-place though!
      bval = np.arange(5)
      b.set_value(bval, borrow=True)
      bval = data_of(b)
      f = pfunc(
          [],
          [b_out],
          updates=[(b, (b_out + 3))],
          mode=get_mode("FAST_RUN").excluding("fusion"),
      )
      assert (f() == (np.arange(5) * 2)).all()
      # because of the update
      assert (
          b.get_value(borrow=True) == ((np.arange(5) * 2) + 3)
      ).all()
      # bval got modified to something...
      assert not (bval == np.arange(5)).all()
      # ... but not to b.value !
      assert not (bval == b.get_value(borrow=True)).all()
  
imports: import numpy
  import pytest
  import pytensor.tensor
  from pytensor.compile import UnusedInputError, get_mode
  from pytensor.compile.function import function, pfunc
  from pytensor.compile.function.pfunc import rebuild_collect_shared
  from pytensor.compile.io import In
  from pytensor.compile.sharedvalue import shared
  from pytensor.configdefaults import config
  from pytensor.graph.utils import MissingInputError
  from pytensor.misc.safe_asarray import _asarray
  from pytensor.tensor.math import sum
  from pytensor.tensor.type import bscalar, bvector, dmatrices, dmatrix, dscalar, dvector, fscalar, fvector, imatrix, iscalar, ivector, ivectors, lscalar, wvector
  from pytensor.utils import PYTHON_INT_BITWIDTH
label_desc: Use image node_id 9 for calling the TestPfunc obj's underlying member method code with example usage: obj.test_shared_mutable() without return types