class_docstr: Parses the inputs and outputs of `Scan` in an easy to manipulate format.
class_docstr_tok: ["Parses","the","inputs","and","outputs","of","`","Scan","`","in","an","easy","to","manipulate","format","."]
code: def get_dependent_nodes(
      self, i: Variable, seen: Optional[set[Variable]] = None
  ) -> set[Variable]:
      if seen is None:
          seen = {i}
      else:
          seen.add(i)
  
      var_mappings = self.var_mappings
  
      field_info = self.find_among_fields(i)
  
      if field_info is None:
          raise ValueError(f"{i} not found among fields.")
  
      # Find the `var_mappings` key suffix that matches the field/set of
      # arguments containing our source node
      if field_info.name[:8].endswith("_in"):
          map_key_suffix = f"{field_info.name[:8]}p"
      else:
          map_key_suffix = field_info.name[:9]
  
      dependent_nodes = set()
      for k, v in var_mappings.items():
          if not k.endswith(map_key_suffix):
              continue
  
          dependent_idx = v[field_info.agg_index]
          dependent_idx = (
              dependent_idx
              if isinstance(dependent_idx, list)
              else [dependent_idx]
          )
  
          # Get the `ScanArgs` field name for the aggregate list property
          # corresponding to these dependent argument types (i.e. either
          # "outer_inputs", "inner_inputs", "inner_outputs", or
          # "outer_outputs").
          # To do this, we need to parse the "shared" prefix of the
          # current `var_mappings` key and append the missing parts so that
          # it either forms `"*_inputs"` or `"*_outputs"`.
          to_agg_field_prefix = k[:9]
          if to_agg_field_prefix.endswith("p"):
              to_agg_field_name = f"{to_agg_field_prefix}uts"
          else:
              to_agg_field_name = f"{to_agg_field_prefix}puts"
  
          to_agg_field = getattr(self, to_agg_field_name)
  
          for d_id in dependent_idx:
              if d_id < 0:
                  continue
  
              dependent_var = to_agg_field[d_id]
  
              if dependent_var not in seen:
                  dependent_nodes.add(dependent_var)
  
      if field_info.name.startswith("inner_in"):
          # If starting from an inner-input, then we need to find any
          # inner-outputs that depend on it.
          for out_n in self.inner_outputs:
              if i in graph_inputs([out_n]):
                  if out_n not in seen:
                      dependent_nodes.add(out_n)
  
      for n in tuple(dependent_nodes):
          if n in seen:
              continue
          sub_dependent_nodes = self.get_dependent_nodes(n, seen=seen)
          dependent_nodes |= sub_dependent_nodes
          seen |= sub_dependent_nodes
  
      return dependent_nodes
  
imports: import copy
  import dataclasses
  import logging
  from collections import OrderedDict, namedtuple
  from collections.abc import Sequence
  from itertools import chain
  from typing import TYPE_CHECKING, Callable, Optional, Union
  from typing import cast
  import numpy
  from pytensor import scalar
  from pytensor import tensor
  from pytensor.compile.profiling import ProfileStats
  from pytensor.configdefaults import config
  from pytensor.graph.basic import Constant, Variable, equal_computations, graph_inputs
  from pytensor.graph.op import get_test_value
  from pytensor.graph.replace import clone_replace
  from pytensor.graph.type import HasDataType
  from pytensor.graph.utils import TestValueError
  from pytensor.tensor.basic import AllocEmpty, cast
  from pytensor.tensor.subtensor import set_subtensor
  from pytensor.tensor.variable import TensorConstant
label_desc: Use image node_id 16 for calling the ScanArgs obj's underlying member method code with example usage: obj.get_dependent_nodes(i, seen) and returns: dependent_nodes