docstr: `FunctionGraph` allows cycles--for better or worse.
docstr_tok: ["`","FunctionGraph","`","allows","cycles","--","for","better","or","worse","."]
code: def test_replace_circular(self):
      """`FunctionGraph` allows cycles--for better or worse."""
  
      var1 = MyVariable("var1")
      var2 = MyVariable("var2")
      var3 = op1(var2, var1)
      var4 = op2(var3, var2)
      var5 = op3(var4, var2, var2)
      fg = FunctionGraph([var1, var2], [var3, var5], clone=False)
  
      fg.replace_all([(var3, var4)])
  
      # The following works (and is kind of gross), because `var4` has been
      # mutated in-place
      assert fg.apply_nodes == {var4.owner, var5.owner}
      assert var4.owner.inputs == [var4, var2]
  
imports: import pickle
  import numpy
  import pytest
  from pytensor.configdefaults import config
  from pytensor.graph.basic import NominalVariable
  from pytensor.graph.fg import FunctionGraph
  from pytensor.graph.utils import MissingInputError
  from tests.graph.utils import MyConstant, MyOp, MyType, MyVariable, MyVariable2, op1, op2, op3
label_desc: Use image node_id 11 for calling the TestFunctionGraph obj's underlying member method code with example usage: obj.test_replace_circular() without return types