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","."]
docstr: Find the type and indices of the field containing a given element.
  
  NOTE: This only returns the *first* field containing the given element.
  
  Parameters
  ----------
  i:
      The element to find among this object's fields.
  field_filter:
      A function passed to `filter` that determines which fields to
      consider.  It must take a string field name and return a truthy
      value.
  
  Returns
  -------
  A tuple of length 4 containing the field name string, the first index,
  the second index (for nested lists), and the "major" index (i.e. the
  index within the aggregate lists like `self.inner_inputs`,
  `self.outer_outputs`, etc.), or a triple of `None` when no match is
  found.
docstr_tok: ["Find","the","type","and","indices","of","the","field","containing","a","given","element",".","NOTE",":","This","only","returns","the","*","first","*","field","containing","the","given","element",".","Parameters","--","--","--","--","--","i",":","The","element","to","find","among","this","object","'s","fields",".","field_filter",":","A","function","passed","to","`","filter","`","that","determines","which","fields","to","consider",".","It","must","take","a","string","field","name","and","return","a","truthy","value",".","Returns","--","--","--","-","A","tuple","of","length","4","containing","the","field","name","string",",","the","first","index",",","the","second","index","(","for","nested","lists",")",",","and","the","``","major","''","index","(","i.e",".","the","index","within","the","aggregate","lists","like","`","self.inner_inputs","`",",","`","self.outer_outputs","`",",","etc",".",")",",","or","a","triple","of","`","None","`","when","no","match","is","found","."]
code: def find_among_fields(
      self,
      i: Variable,
      field_filter: Callable[[str], bool] = default_filter,
  ) -> Optional[FieldInfo]:
      """Find the type and indices of the field containing a given element.
  
      NOTE: This only returns the *first* field containing the given element.
  
      Parameters
      ----------
      i:
          The element to find among this object's fields.
      field_filter:
          A function passed to `filter` that determines which fields to
          consider.  It must take a string field name and return a truthy
          value.
  
      Returns
      -------
      A tuple of length 4 containing the field name string, the first index,
      the second index (for nested lists), and the "major" index (i.e. the
      index within the aggregate lists like `self.inner_inputs`,
      `self.outer_outputs`, etc.), or a triple of `None` when no match is
      found.
      """
  
      field_names = filter(field_filter, self.field_names)
  
      for field_name in field_names:
          lst = getattr(self, field_name)
  
          field_prefix = field_name[:8]
          if field_prefix.endswith("in"):
              agg_field_name = f"{field_prefix}puts"
          else:
              agg_field_name = f"{field_prefix}tputs"
  
          agg_list = getattr(self, agg_field_name)
  
          if field_name in self.nested_list_fields:
              for n, sub_lst in enumerate(lst):
                  idx = safe_index(sub_lst, i)
                  if idx is not None:
                      agg_idx = safe_index(agg_list, i)
                      return FieldInfo(
                          field_name, agg_field_name, n, idx, agg_idx
                      )
          else:
              idx = safe_index(lst, i)
              if idx is not None:
                  agg_idx = safe_index(agg_list, i)
                  return FieldInfo(
                      field_name, agg_field_name, idx, None, agg_idx
                  )
  
      return None
  
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 14 for calling the ScanArgs obj's underlying member method code with example usage: obj.find_among_fields(i, field_filter) and returns: None, FieldInfo, FieldInfo