code: def get_stack_mixture_vars(
      node: Apply,
  ) -> Tuple[Optional[List[TensorVariable]], Optional[int]]:
      r"""Extract the mixture terms from a `*Subtensor*` applied to stacked `MeasurableVariable`\s."""
  
      assert isinstance(node.op, subtensor_ops)
  
      joined_rvs = node.inputs[0]
  
      # First, make sure that it's some sort of concatenation
      if not (
          joined_rvs.owner
          and isinstance(joined_rvs.owner.op, (MakeVector, Join))
      ):
          return None, None
  
      if isinstance(joined_rvs.owner.op, MakeVector):
          join_axis = NoneConst
          mixture_rvs = joined_rvs.owner.inputs
  
      elif isinstance(joined_rvs.owner.op, Join):
          join_axis = joined_rvs.owner.inputs[0]
          # TODO: Support symbolic join axes. This will raise ValueError if it's not a constant
          (join_axis,) = constant_fold(
              (join_axis,), raise_not_constant=False
          )
          join_axis = pt.as_tensor(join_axis, dtype="int64")
  
          mixture_rvs = joined_rvs.owner.inputs[1:]
  
      return mixture_rvs, join_axis
  
imports: from typing import List, Optional, Tuple, Union, cast
  import pytensor
  import pytensor.tensor
  from pytensor.graph.basic import Apply, Constant, Variable
  from pytensor.graph.fg import FunctionGraph
  from pytensor.graph.op import Op, compute_test_value
  from pytensor.graph.rewriting.basic import EquilibriumGraphRewriter, node_rewriter
  from pytensor.ifelse import IfElse, ifelse
  from pytensor.scalar import Switch
  from pytensor.scalar import switch
  from pytensor.tensor.basic import Join, MakeVector, switch
  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
  from pytensor.tensor.shape import shape_tuple
  from pytensor.tensor.subtensor import AdvancedSubtensor, AdvancedSubtensor1, as_index_literal, get_canonical_form_slice, is_basic_idx
  from pytensor.tensor.type import TensorType
  from pytensor.tensor.type_other import NoneConst, NoneTypeT, SliceConstant, SliceType
  from pytensor.tensor.variable import TensorVariable
  from pymc.logprob.abstract import MeasurableElemwise, MeasurableVariable, _logprob, _logprob_helper
  from pymc.logprob.rewriting import PreserveRVMappings, assume_measured_ir_outputs, local_lift_DiracDelta, measurable_ir_rewrites_db, subtensor_ops
  from pymc.logprob.utils import check_potential_measurability, replace_rvs_by_values
  from pymc.pytensorf import constant_fold
label_desc: Use image node_id 4 for calling a global function with example usage: get_stack_mixture_vars(node) and returns: mixture_rvs,  join_axis, None,  None