code: def test_partial_input_aliasing_affecting_inplace_operations(self):
      # Note: to trigger this bug with pytensor rev 4586:2bc6fc7f218b,
      #        you need to make in inputs mutable ( so that inplace
      #        operations are used) and to break the elemwise composition
      #        with some non-elemwise op ( here dot )
      x = dvector()
      y = dvector()
      z = dvector()
      m1 = dmatrix()
      m2 = dmatrix()
      m3 = dmatrix()
  
      # Test 2. If variables only partial overlap
      #   more exactly we care about the case when we have a,b,c
      #   and a shares memory with b, b shares memory with c, but
      #   c does not share memory with a
  
      f = function(
          [
              In(x, mutable=True),
              In(y, mutable=True),
              In(z, mutable=True),
              In(m1, mutable=True),
              In(m2, mutable=True),
              In(m3, mutable=True),
          ],
          (
              pt.dot((x * 2), m1)
              + pt.dot((y * 3), m2)
              + pt.dot((z * 4), m3)
          ),
      )
  
      # Compute bogus values
      v = np.asarray([1, 2, 3, 4, 5], dtype="float64")
      m = np.asarray([[1, 0], [0, 1]], dtype="float64")
      bogus_vals = f(v[:2], v[1:3], v[2:4], m, m, m)
      # Since we used inplace operation v and m may be corrupted
      # so we need to recreate them
  
      v = np.asarray([1, 2, 3, 4, 5], dtype="float64")
      m = np.asarray([[1, 0], [0, 1]], dtype="float64")
      m_copy1 = m.copy()
      v_copy1 = v.copy()
      m_copy2 = m.copy()
      v_copy2 = v.copy()
      vals = f(v[:2], v_copy1[1:3], v_copy2[2:4], m, m_copy1, m_copy2)
  
      assert np.allclose(vals, bogus_vals)
  
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 5 for calling the TestAliasingRules obj's underlying member method code with example usage: obj.test_partial_input_aliasing_affecting_inplace_operations() without return types