code: def main(infile, outfile, with_threads=False):
      with rasterio.Env():
          # Open the source dataset.
          with rasterio.open(infile) as src:
              # Create a destination dataset based on source params. The
              # destination will be tiled, and we'll "process" the tiles
              # concurrently.
  
              meta = src.meta
              meta.update(blockxsize=256, blockysize=256, tiled="yes")
              with rasterio.open(outfile, "w", **meta) as dst:
                  loop = asyncio.get_event_loop()
  
                  # With the exception of the ``yield from`` statement,
                  # process_window() looks like callback-free synchronous
                  # code. With a coroutine, we can keep the read, compute,
                  # and write statements close together for
                  # maintainability. As in the concurrent-cpu-bound.py
                  # example, all of the speedup is provided by
                  # distributing raster computation across multiple
                  # threads. The difference here is that we're submitting
                  # jobs to the thread pool asynchronously.
  
                  @asyncio.coroutine
                  def process_window(window):
                      # Read a window of data.
                      data = src.read(window=window)
  
                      # We run the raster computation in a separate thread
                      # and pause until the computation finishes, letting
                      # other coroutines advance.
                      #
                      # The _example.compute function modifies no Python
                      # objects and releases the GIL. It can execute
                      # concurrently.
                      result = np.zeros(data.shape, dtype=data.dtype)
                      if with_threads:
                          yield from loop.run_in_executor(
                              None, compute, data, result
                          )
                      else:
                          compute(data, result)
  
                      dst.write(result, window=window)
  
                  # Queue up the loop's tasks.
                  tasks = [
                      asyncio.Task(process_window(window))
                      for ij, window in dst.block_windows(1)
                  ]
  
                  # Wait for all the tasks to finish, and close.
                  loop.run_until_complete(asyncio.wait(tasks))
                  loop.close()
  
imports: import asyncio
  import numpy
  import rasterio
  from rasterio._example import compute
label_desc: Use image node_id 1 for calling a global function with example usage: main(infile, outfile, with_threads) without return types