code: def test_replace(self):
      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)
  
      with pytest.raises(TypeError):
          var0 = MyVariable2("var0")
          # The types don't match and one cannot be converted to the other
          fg.replace(var3, var0)
  
      # Test a basic replacement
      fg.replace_all([(var3, var1)])
      assert var3 not in fg.variables
      assert fg.apply_nodes == {var4.owner, var5.owner}
      assert var4.owner.inputs == [var1, 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 9 for calling the TestFunctionGraph obj's underlying member method code with example usage: obj.test_replace() without return types