def _construct_test_graph(
        context, test_op, test_node, output_name=None, graph_inputs=None, constants=None
    ):
        """ Construct an Function for the given @graph_inputs, @constants,
            and @test_node. Returns the output of the graph, which is the ssa
            Var of the given @output_name.
        """
        if graph_inputs is None:
            graph_inputs = {}
        if constants is None:
            constants = []

        with Function(inputs=graph_inputs) as ssa_func:
            for name in ssa_func.inputs.keys():
                context.add(ssa_func.inputs[name])
            for node in constants:
                ops.constant(context, node)
            test_op(context, test_node)

        ssa = None
        if output_name:
            ssa = context[output_name]
        return ssa
 Construct an Function for the given @graph_inputs, @constants,
            and @test_node. Returns the output of the graph, which is the ssa
            Var of the given @output_name.
        
coremltools/converters/mil/frontend/torch/test/test_internal_graph.py