code: def test_data(inline_views):
      """Test shared RNGs, MutableData, ConstantData and dim lengths are handled correctly.
  
      All model-related shared variables should be copied to become independent across models.
      """
      with pm.Model(coords_mutable={"test_dim": range(3)}) as m_old:
          x = pm.MutableData("x", [0.0, 1.0, 2.0], dims=("test_dim",))
          y = pm.MutableData(
              "y", [10.0, 11.0, 12.0], dims=("test_dim",)
          )
          b0 = pm.ConstantData("b0", np.zeros((1,)))
          b1 = pm.DiracDelta("b1", 1.0)
          mu = pm.Deterministic("mu", b0 + b1 * x, dims=("test_dim",))
          obs = pm.Normal(
              "obs", mu, sigma=1e-5, observed=y, dims=("test_dim",)
          )
  
      m_fgraph, memo = fgraph_from_model(
          m_old, inlined_views=inline_views
      )
      assert isinstance(memo[x].owner.op, ModelNamed)
      assert isinstance(memo[y].owner.op, ModelNamed)
      assert isinstance(memo[b0].owner.op, ModelNamed)
      mu_inp = memo[mu].owner.inputs[0]
      obs = memo[obs]
      if not inline_views:
          # Add(b0, Mul(FreeRV(b1), x) not Add(Named(b0), Mul(FreeRV(b1), Named(x))
          assert mu_inp.owner.inputs[0] is memo[b0].owner.inputs[0]
          assert (
              mu_inp.owner.inputs[1].owner.inputs[1]
              is memo[x].owner.inputs[0]
          )
          # ObservedRV(obs, y, *dims) not ObservedRV(obs, Named(y), *dims)
          assert obs.owner.inputs[1] is memo[y].owner.inputs[0]
      else:
          assert mu_inp.owner.inputs[0] is memo[b0]
          assert mu_inp.owner.inputs[1].owner.inputs[1] is memo[x]
          assert obs.owner.inputs[1] is memo[y]
  
      m_new = model_from_fgraph(m_fgraph)
  
      # The rv-data mapping is preserved
      assert m_new.rvs_to_values[m_new["obs"]] is m_new["y"]
  
      # ConstantData is still accessible as a model variable
      np.testing.assert_array_equal(m_new["b0"], m_old["b0"])
  
      # Shared model variables, dim lengths, and rngs are copied and no longer point to the same memory
      assert not same_storage(m_new["x"], x)
      assert not same_storage(m_new["y"], y)
      assert not same_storage(
          m_new["b1"].owner.inputs[0], b1.owner.inputs[0]
      )
      assert not same_storage(
          m_new.dim_lengths["test_dim"], m_old.dim_lengths["test_dim"]
      )
  
      # Updating model shared variables in new model, doesn't affect old one
      with m_new:
          pm.set_data(
              {"x": [100.0, 200.0]}, coords={"test_dim": range(2)}
          )
      assert m_new.dim_lengths["test_dim"].eval() == 2
      assert m_old.dim_lengths["test_dim"].eval() == 3
      np.testing.assert_allclose(pm.draw(m_new["mu"]), [100.0, 200.0])
      np.testing.assert_allclose(
          pm.draw(m_old["mu"]), [0.0, 1.0, 2.0], atol=1e-6
      )
  
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 3 for calling a global function with example usage: test_data(inline_views) without return types