code: def test_persist_inputs():
      """Make sure we don't unnecessarily clone variables."""
      x = pt.scalar("x")
      beta_rv = pt.random.normal(0, 1, name="beta")
      Y_rv = pt.random.normal(beta_rv * x, 1, name="y")
  
      beta_vv = beta_rv.type()
      y_vv = Y_rv.clone()
  
      logp = conditional_logp({beta_rv: beta_vv, Y_rv: y_vv})
      logp_combined = pt.sum(
          [pt.sum(factor) for factor in logp.values()]
      )
  
      assert x in ancestors([logp_combined])
  
      # Make sure we don't clone value variables when they're graphs.
      y_vv_2 = y_vv * 2
      logp_2 = conditional_logp({beta_rv: beta_vv, Y_rv: y_vv_2})
      logp_2_combined = pt.sum(
          [pt.sum(factor) for factor in logp_2.values()]
      )
  
      assert y_vv in ancestors([logp_2_combined])
      assert y_vv_2 in ancestors([logp_2_combined])
  
      # Even when they are random
      y_vv = pt.random.normal(name="y_vv2")
      y_vv_2 = y_vv * 2
      logp_2 = conditional_logp({beta_rv: beta_vv, Y_rv: y_vv_2})
      logp_2_combined = pt.sum(
          [pt.sum(factor) for factor in logp_2.values()]
      )
  
      assert y_vv in ancestors([logp_2_combined])
      assert y_vv_2 in ancestors([logp_2_combined])
  
imports: import warnings
  import numpy
  import pytensor
  import pytensor.tensor
  import pytest
  import scipy.stats.distributions
  from pytensor.graph.basic import ancestors, equal_computations
  from pytensor.tensor.random.op import RandomVariable
  from pytensor.tensor.subtensor import AdvancedIncSubtensor, AdvancedIncSubtensor1, IncSubtensor
  import pymc
  from pymc.logprob.basic import conditional_logp, icdf, logcdf, logp, transformed_conditional_logp
  from pymc.logprob.transforms import LogTransform
  from pymc.logprob.utils import replace_rvs_by_values
  from pymc.testing import assert_no_rvs
label_desc: Use image node_id 5 for calling a global function with example usage: test_persist_inputs() without return types