code: def test_Subtensor_lift(indices, lifted, dist_op, dist_params, size):
      from pytensor.tensor.subtensor import as_index_constant
  
      rng = shared(np.random.default_rng(1233532), borrow=False)
  
      indices_pt = ()
      for i in indices:
          i_pt = as_index_constant(i)
          if not isinstance(i_pt, slice):
              i_pt.tag.test_value = i
          indices_pt += (i_pt,)
  
      (
          new_out,
          f_inputs,
          dist_st,
          f_rewritten,
      ) = apply_local_rewrite_to_rv(
          local_subtensor_rv_lift,
          lambda rv: rv[indices_pt],
          dist_op,
          dist_params,
          size,
          rng,
      )
  
      if lifted:
          assert isinstance(new_out.owner.op, RandomVariable)
          assert all(
              isinstance(
                  i.owner.op,
                  (AdvancedSubtensor, AdvancedSubtensor1, Subtensor),
              )
              for i in new_out.owner.inputs[3:]
              if i.owner
          )
      else:
          assert isinstance(
              new_out.owner.op,
              (AdvancedSubtensor, AdvancedSubtensor1, Subtensor),
          )
          return
  
      f_base = function(
          f_inputs,
          dist_st,
          mode=no_mode,
      )
  
      arg_values = [p.get_test_value() for p in f_inputs]
      res_base = f_base(*arg_values)
      res_rewritten = f_rewritten(*arg_values)
  
      np.testing.assert_allclose(
          res_base, res_rewritten, rtol=1e-3, atol=1e-2
      )
  
imports: import numpy
  import pytest
  import pytensor.tensor
  from pytensor import config, shared
  from pytensor.compile.function import function
  from pytensor.compile.mode import Mode
  from pytensor.graph.basic import Constant
  from pytensor.graph.fg import FunctionGraph
  from pytensor.graph.rewriting.basic import EquilibriumGraphRewriter
  from pytensor.graph.rewriting.db import RewriteDatabaseQuery
  from pytensor.tensor import constant
  from pytensor.tensor.elemwise import DimShuffle
  from pytensor.tensor.random.basic import categorical, dirichlet, multinomial, multivariate_normal, normal, poisson, uniform
  from pytensor.tensor.random.op import RandomVariable
  from pytensor.tensor.random.rewriting import local_dimshuffle_rv_lift, local_rv_size_lift, local_subtensor_rv_lift
  from pytensor.tensor.rewriting.shape import ShapeFeature, ShapeOptimizer
  from pytensor.tensor.subtensor import AdvancedSubtensor, AdvancedSubtensor1, Subtensor
  from pytensor.tensor.type import iscalar, vector
label_desc: Use image node_id 7 for calling a global function with example usage: test_Subtensor_lift(indices, lifted, dist_op, dist_params, size) without return types