code: def test_context_error():
      """Test that model_from_fgraph fails when called inside a Model context.
  
      We can't allow it, because the new Model that's returned would be a child of whatever Model context is active.
      """
      with pm.Model() as m:
          x = pm.Normal("x")
  
          fg = fgraph_from_model(m)
  
          with pytest.raises(
              RuntimeError,
              match="cannot be called inside a PyMC model context",
          ):
              model_from_fgraph(fg)
  
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 6 for calling a global function with example usage: test_context_error() without return types