code: def createAndRunNetwork(
      testRegionType,
      testOutputName,
      checkpointMidway=False,
      temporalImp=None,
  ):
      dataSource = FileRecordStream(streamID=_INPUT_FILE_PATH)
  
      if temporalImp is None:
          network = createNetwork(dataSource)
      else:
          network = createNetwork(
              dataSource, enableTP=True, temporalImp=temporalImp
          )
      network.initialize()
  
      results = []
  
      for i in xrange(_NUM_RECORDS):
          if checkpointMidway and i == (_NUM_RECORDS / 2):
              network = saveAndLoadNetwork(network)
  
          # Run the network for a single iteration
          network.run(1)
  
          testRegion = network.getRegionsByType(testRegionType)[0]
          output = testRegion.getOutputData(testOutputName).copy()
          results.append(output)
  
      return results
  
file_path: nupic-legacy/tests/integration/nupic/engine/network_creation_common.py
imports: import copy
  import csv
  import json
  import os
  import tempfile
  from pkg_resources import resource_filename
  from nupic.data.file_record_stream import FileRecordStream
  from nupic.engine import Network
  from nupic.encoders import MultiEncoder, ScalarEncoder, DateEncoder
  from nupic.regions.record_sensor import RecordSensor
  from nupic.regions.sp_region import SPRegion
  from nupic.regions.tm_region import TMRegion
label_desc: Use image node_id 4 for calling a global function with example usage: createAndRunNetwork(testRegionType, testOutputName, checkpointMidway, temporalImp) and returns: results