code: def test_sub_model_error():
      """Test Error is raised when trying to convert a sub-model to fgraph."""
      with pm.Model() as m:
          x = pm.Beta("x", 1, 1)
          with pm.Model() as sub_m:
              y = pm.Normal("y", x)
  
      nodes = [
          v
          for v in fgraph_from_model(m)[0].toposort()
          if not isinstance(v.op, ModelVar)
      ]
      assert len(nodes) == 2
      assert isinstance(nodes[0].op, pm.Beta)
      assert isinstance(nodes[1].op, pm.Normal)
  
      with pytest.raises(
          ValueError, match="Nested sub-models cannot be converted"
      ):
          fgraph_from_model(sub_m)
  
file_path: pymc/tests/model/test_fgraph.py
imports: import numpy
  import pytensor.tensor
  import pytest
  from pytensor import config, shared
  from pytensor.graph import Constant, FunctionGraph, node_rewriter
  from pytensor.graph.rewriting.basic import in2out
  from pytensor.tensor.exceptions import NotScalarConstantError
  import pymc
  from pymc.model.fgraph import ModelDeterministic, ModelFreeRV, ModelNamed, ModelObservedRV, ModelPotential, ModelVar, clone_model, fgraph_from_model, model_deterministic, model_free_rv, model_from_fgraph
label_desc: Use image node_id 7 for calling a global function with example usage: test_sub_model_error() without return types