class_docstr: Runtime Module.
class_docstr_tok: ["Runtime","Module","."]
docstr: Helper function to collect modules from the tree matching a filter_func, then return it.
  
  Parameters
  ----------
  filter_func : Callable[[Module], bool]
      A function which is invoked for each Module discovered in the import tree (including
      self).
  
  Returns
  -------
  list[Module] :
      A list of matching Module.
docstr_tok: ["Helper","function","to","collect","modules","from","the","tree","matching","a","filter_func",",","then","return","it",".","Parameters","--","--","--","--","--","filter_func",":","Callable","[","[","Module","]",",","bool","]","A","function","which","is","invoked","for","each","Module","discovered","in","the","import","tree","(","including","self",")",".","Returns","--","--","--","-","list","[","Module","]",":","A","list","of","matching","Module","."]
code: def _collect_from_import_tree(self, filter_func):
      """Helper function to collect modules from the tree matching a filter_func, then return it.
  
      Parameters
      ----------
      filter_func : Callable[[Module], bool]
          A function which is invoked for each Module discovered in the import tree (including
          self).
  
      Returns
      -------
      list[Module] :
          A list of matching Module.
      """
      visited, stack, dso_modules = set(), [], []
      # append root module
      visited.add(self)
      stack.append(self)
      while stack:
          module = stack.pop()
          assert (
              module.is_dso_exportable or module.is_binary_serializable
          ), f"Module {module.type_key} should be either dso exportable or binary serializable."
  
          if filter_func(module):
              dso_modules.append(module)
          for m in module.imported_modules:
              if m not in visited:
                  visited.add(m)
                  stack.append(m)
      return dso_modules
  
imports: import os
  import ctypes
  import struct
  from typing import Sequence
  import numpy
  from tvm._ffi.base import _LIB, check_call, c_str, string_types, _RUNTIME_ONLY
  from tvm._ffi.libinfo import find_include_path
  from .packed_func import PackedFunc, PackedFuncHandle, _set_class_module
  from .None import _ffi_api
label_desc: Use image node_id 22 for calling the Module obj's underlying member method code with example usage: obj._collect_from_import_tree(filter_func) and returns: dso_modules