def convert_nodes(
    context: TranscriptionContext,
    graph: InternalTorchIRGraph,
    early_exit: Optional[bool] = True,
) -> None:
    """
    Iterate over the nodes of a graph or block and convert to MIL.

    Arguments:
        context: A TranscriptionContext object to pull node inputs and assign node outputs.
        graph: An InternalTorchIRGraph or InternalTorchIRBlock object.
    """
    for node in _tqdm(graph.nodes, desc="Converting PyTorch Frontend ==> MIL Ops", unit=" ops"):
        try:
            convert_single_node(context, node)
        except Exception as e:
            scope_names = node.get_scope_info()[0]
            op_location = '/'.join(scope_names)
            logger.error(f"\n\nERROR - converting '{node.kind}' op (located at: '{op_location}'):\n")
            raise e     # re-raise exception

        if early_exit and _all_outputs_present(context, graph):
            # We've generated all the outputs the graph needs, terminate conversion.
            break

    Iterate over the nodes of a graph or block and convert to MIL.

    Arguments:
        context: A TranscriptionContext object to pull node inputs and assign node outputs.
        graph: An InternalTorchIRGraph or InternalTorchIRBlock object.
    
coremltools/converters/mil/frontend/torch/ops.py