def main(file_name, jobs):
    in1out2 = NMFunction(n=1, m=2)
    in1out2.__metatype__ = "ADAPTER"
    in1out2.set_parameter("function", datasets)
    abs_reader = HigherOrderComponent(multiple_outputs_reader(m=3))
    df_reader = HigherOrderComponent(multiple_outputs_reader(m=2))
    feature_segmentation = ThicknessFeatureSegmentation()
    feature_segmentation_out = NMFunction(m=3)
    log_ratio = NMFunction(n=2)
    log_ratio.set_parameter(
        "function",
        log_function)
    average_abs = average()
    average_df = average()
    average_r = average()
    network = {
        in1out2: {
            abs_reader: ("out", "in"),
            df_reader: ("out1", "in"),
        },
        abs_reader: {
            average_abs: ("out", "in"),
            feature_segmentation: ("out1", "in"),
            log_ratio: ("out2", "in1")
        },
        df_reader: {
            log_ratio: ("out", "in"),
            average_df: ("out1", "in")
        },
        feature_segmentation: {
            feature_segmentation_out: ("out", "in")
        },
        log_ratio: {
            average_r: ("out", "in")
        },
        feature_segmentation_out: {
            average_abs: ("out", "in1"),
            average_df: ("out1", "in1"),
            average_r: ("out2", "in1")
        },
    }
    pipeline = pypes.pipeline.Dataflow(network, n=jobs)
    packet = pypes.packet.Packet()
    packet.set("file_name", file_name)
    pipeline.send(packet)
    pipeline.close()
def average():
    "calculate weighted average"
    average = NMFunction(n=2)
    average.set_parameter(
        "function", average_function)
    return average