def get_object_type_filter(tp: _Callable):
    """
    Returns a filter which returns True if a node in the final exported graph
    was created because of an object of type ``tp``
    """

    def object_type_filter(n: _Node) -> bool:
        # example: {
        #     'add_10': ('add', <function _operator.add(a, b, /)>)
        # }
        nn_module_stack = n.meta.get("nn_module_stack", {})
        types = [t for _, t in nn_module_stack.values()]
        source_fn_stack = n.meta.get("source_fn_stack", {})
        types.extend([t for _, t in source_fn_stack])
        return tp in types

    return object_type_filter

    Returns a filter which returns True if a node in the final exported graph
    was created because of an object of type ``tp``
    
coremltools/optimize/torch/quantization/_coreml_quantizer_utils.py