code: def test_function(tmpdir):
      tmpdir.chdir()
  
      def gen_random_array(size):
          import numpy as np
  
          return np.random.rand(size, size)
  
      f1 = pe.MapNode(
          utility.Function(
              input_names=["size"],
              output_names=["random_array"],
              function=gen_random_array,
          ),
          name="random_array",
          iterfield=["size"],
      )
      f1.inputs.size = [2, 3, 5]
  
      wf = pe.Workflow(name="test_workflow")
  
      def increment_array(in_array):
          return in_array + 1
  
      f2 = pe.MapNode(
          utility.Function(function=increment_array),
          name="increment_array",
          iterfield=["in_array"],
      )
  
      wf.connect(f1, "random_array", f2, "in_array")
  
      f3 = pe.Node(
          utility.Function(function=concat_sort), name="concat_sort"
      )
  
      wf.connect(f2, "out", f3, "in_arrays")
      wf.run()
  
file_path: nipype/nipype/interfaces/utility/tests/test_wrappers.py
imports: import os
  import pytest
  from nipype.interfaces import utility
  import nipype.pipeline.engine
label_desc: Use image node_id 1 for calling a global function with example usage: test_function(tmpdir) and returns: np, unknown