code: def check_potential_measurability(
      inputs: Tuple[TensorVariable],
      valued_rvs: Container[TensorVariable],
  ) -> bool:
      valued_rvs = set(valued_rvs)
  
      def expand_fn(var):
          # expand_fn does not go beyond valued_rvs or any MeasurableVariable
          if (
              var.owner
              and not isinstance(var.owner.op, MeasurableVariable)
              and var not in valued_rvs
          ):
              return reversed(var.owner.inputs)
          else:
              return []
  
      if any(
          ancestor_var
          for ancestor_var in walk(inputs, expand=expand_fn, bfs=False)
          if (
              ancestor_var.owner
              and isinstance(ancestor_var.owner.op, MeasurableVariable)
              and ancestor_var not in valued_rvs
          )
      ):
          return True
      return False
  
imports: import typing
  import warnings
  from typing import Container, Dict, List, Optional, Sequence, Set, Tuple, Union
  import numpy
  import pytensor
  from pytensor import Variable
  from pytensor import tensor
  from pytensor.graph import Apply, Op, node_rewriter
  from pytensor.graph.basic import Constant, clone_get_equiv, graph_inputs, walk
  from pytensor.graph.op import HasInnerGraph
  from pytensor.link.c.type import CType
  from pytensor.raise_op import CheckAndRaise
  from pytensor.tensor.random.op import RandomVariable
  from pytensor.tensor.variable import TensorVariable
  from pymc.logprob.abstract import MeasurableVariable, _logprob
  from pymc.pytensorf import replace_vars_in_graphs
  from pymc.util import makeiter
label_desc: Use image node_id 5 for calling a global function with example usage: check_potential_measurability(inputs, valued_rvs) and returns: False, True, reversed, list