diff --git a/nipype/interfaces/utility/base.py b/nipype/interfaces/utility/base.py
index 45261c998..03442df20 100644
--- a/nipype/interfaces/utility/base.py
+++ b/nipype/interfaces/utility/base.py
@@ -99,13 +99,29 @@ class IdentityInterface(IOBase):
 class MergeInputSpec(DynamicTraitedSpec, BaseInterfaceInputSpec):
     axis = traits.Enum('vstack', 'hstack', usedefault=True,
                        desc='direction in which to merge, hstack requires same number of elements in each input')
-    no_flatten = traits.Bool(False, usedefault=True, desc='append to outlist instead of extending in vstack mode')
+    no_flatten = traits.Bool(False, usedefault=True,
+                             desc='append to outlist instead of extending in vstack mode')
+    ravel_inputs = traits.Bool(False, usedefault=True,
+                               desc='ravel inputs when no_flatten is False')
 
 
 class MergeOutputSpec(TraitedSpec):
     out = traits.List(desc='Merged output')
 
 
+def _ravel(in_val):
+    if not isinstance(in_val, list):
+        return in_val
+    flat_list = []
+    for val in in_val:
+        raveled_val = _ravel(val)
+        if isinstance(raveled_val, list):
+            flat_list.extend(raveled_val)
+        else:
+            flat_list.append(raveled_val)
+    return flat_list
+
+
 class Merge(IOBase):
     """Basic interface class to merge inputs into a single list
 
@@ -123,23 +139,34 @@ class Merge(IOBase):
     >>> out.outputs.out
     [1, 2, 5, 3]
 
-    >>> merge = Merge()   # Or Merge(1)
-    >>> merge.inputs.in_lists = [1, [2, 5], 3]
+    >>> merge = Merge(1)
+    >>> merge.inputs.in1 = [1, [2, 5], 3]
+    >>> out = merge.run()
+    >>> out.outputs.out
+    [1, [2, 5], 3]
+
+    >>> merge = Merge(1)
+    >>> merge.inputs.in1 = [1, [2, 5], 3]
+    >>> merge.inputs.ravel_inputs = True
     >>> out = merge.run()
     >>> out.outputs.out
     [1, 2, 5, 3]
 
+    >>> merge = Merge(1)
+    >>> merge.inputs.in1 = [1, [2, 5], 3]
+    >>> merge.inputs.no_flatten = True
+    >>> out = merge.run()
+    >>> out.outputs.out
+    [[1, [2, 5], 3]]
     """
     input_spec = MergeInputSpec
     output_spec = MergeOutputSpec
 
-    def __init__(self, numinputs=1, **inputs):
+    def __init__(self, numinputs=0, **inputs):
         super(Merge, self).__init__(**inputs)
         self._numinputs = numinputs
-        if numinputs > 1:
+        if numinputs >= 1:
             input_names = ['in%d' % (i + 1) for i in range(numinputs)]
-        elif numinputs == 1:
-            input_names = ['in_lists']
         else:
             input_names = []
         add_traits(self.inputs, input_names)
@@ -150,8 +177,6 @@ class Merge(IOBase):
 
         if self._numinputs < 1:
             return outputs
-        elif self._numinputs == 1:
-            values = self.inputs.in_lists
         else:
             getval = lambda idx: getattr(self.inputs, 'in%d' % (idx + 1))
             values = [getval(idx) for idx in range(self._numinputs)
@@ -160,7 +185,8 @@ class Merge(IOBase):
         if self.inputs.axis == 'vstack':
             for value in values:
                 if isinstance(value, list) and not self.inputs.no_flatten:
-                    out.extend(value)
+                    out.extend(_ravel(value) if self.inputs.ravel_inputs else
+                               value)
                 else:
                     out.append(value)
         else:

New behaviour of Merge interface with breaks generic cases where numinputs=1 at runtime
### Summary

In the current HEAD, the new behaviour of the Merge interface when `numinputs==1` breaks cases (such as mine) where the `numinputs` is set at runtime depending on parameters of the workflow creation code. A better way to handle this would be to see if `in_lists` is defined or perhaps use `numinputs`==None.

### Actual behavior

`TypeError: '_Undefined' object is not iterable`

### Expected behavior

`in1` is taken to be the only element of the merged list

### How to replicate the behavior

```
import nipype.pipeline.engine as pe
from nipype.interfaces.utility.base import Merge

merge  = pe.Node(Merge(numinputs=1), name='merge')
merge.inputs.in1 = 1

workflow = pe.Workflow(name='workflow')
workflow.add_nodes([merge])
workflow.run()
```

### Platform details:
please paste the output of: `python -c "import nipype; print(nipype.get_info()); print(nipype.__version__)"`

    {'nibabel_version': '2.0.1', 'sys_executable': '/usr/local/opt/python/bin/python2.7', 'networkx_version': '1.11', 'numpy_version': '1.12.0', 'sys_platform': 'darwin', 'sys_version': '2.7.13 (default, Dec 17 2016, 23:03:43) \n[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)]', 'commit_source': u'repository', 'commit_hash': '368e184', 'pkg_path': '/Users/tclose/git/nipype/nipype', 'nipype_version': u'0.13.0-g368e184.dev', 'traits_version': '4.6.0', 'scipy_version': '0.14.0'}
    0.13.0-g368e184.dev
diff --git a/nipype/interfaces/utility/tests/test_base.py b/nipype/interfaces/utility/tests/test_base.py
index 68f4bed44..3d2fbd2b5 100644
--- a/nipype/interfaces/utility/tests/test_base.py
+++ b/nipype/interfaces/utility/tests/test_base.py
@@ -56,25 +56,20 @@ def test_split(tmpdir, args, expected):
         ([3], {}, [0, [1, 2], [3, 4, 5]], [0, 1, 2, 3, 4, 5]),
         ([0], {}, None, None),
         ([], {}, [], []),
-        ([], {}, [0, [1, 2], [3, 4, 5]], [0, 1, 2, 3, 4, 5]),
+        ([], {}, [0, [1, 2], [3, 4, 5]], [0, [1, 2], [3, 4, 5]]),
         ([3], {'axis': 'hstack'}, [[0], [1, 2], [3, 4, 5]], [[0, 1, 3]]),
         ([3], {'axis': 'hstack'}, [[0, 1], [2, 3], [4, 5]],
          [[0, 2, 4], [1, 3, 5]]),
         ([3], {'axis': 'hstack'}, [[0, 1], [2, 3], [4, 5]],
          [[0, 2, 4], [1, 3, 5]]),
-        ([1], {'axis': 'hstack'}, [[0], [1, 2], [3, 4, 5]], [[0, 1, 3]]),
-        ([1], {'axis': 'hstack'}, [[0, 1], [2, 3], [4, 5]],
-         [[0, 2, 4], [1, 3, 5]]),
         ])
 def test_merge(tmpdir, args, kwargs, in_lists, expected):
     os.chdir(str(tmpdir))
 
     node = pe.Node(utility.Merge(*args, **kwargs), name='merge')
 
-    numinputs = args[0] if args else 1
-    if numinputs == 1:
-        node.inputs.in_lists = in_lists
-    elif numinputs > 1:
+    numinputs = args[0] if args else 0
+    if numinputs >= 1:
         for i in range(1, numinputs + 1):
             setattr(node.inputs, 'in{:d}'.format(i), in_lists[i - 1])
 

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest
apt-get update apt-get install -y gcc
3.6
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
attrs==22.2.0
certifi==2021.5.30
click==8.0.4
configparser==5.2.0
coverage==6.2
decorator==4.4.2
funcsigs==1.0.2
future==1.0.0
importlib-metadata==4.8.3
iniconfig==1.1.1
isodate==0.6.1
lxml==5.3.1
networkx==2.5.1
nibabel==3.2.2
-e git+https://github.com/nipy/nipype.git@d68b929ae1f36f2704fa7cddd029b308acf8587a#egg=nipype
numpy==1.19.5
packaging==21.3
pluggy==1.0.0
prov==2.0.1
psutil==7.0.0
py==1.11.0
pyparsing==3.1.4
pytest==7.0.1
pytest-cov==4.0.0
python-dateutil==2.9.0.post0
rdflib==5.0.0
scipy==1.5.4
simplejson==3.20.1
six==1.17.0
tomli==1.2.3
traits==6.4.1
typing_extensions==4.1.1
zipp==3.6.0

name: nipype
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - attrs==22.2.0
      - click==8.0.4
      - configparser==5.2.0
      - coverage==6.2
      - decorator==4.4.2
      - funcsigs==1.0.2
      - future==1.0.0
      - importlib-metadata==4.8.3
      - iniconfig==1.1.1
      - isodate==0.6.1
      - lxml==5.3.1
      - networkx==2.5.1
      - nibabel==3.2.2
      - numpy==1.19.5
      - packaging==21.3
      - pluggy==1.0.0
      - prov==2.0.1
      - psutil==7.0.0
      - py==1.11.0
      - pyparsing==3.1.4
      - pytest==7.0.1
      - pytest-cov==4.0.0
      - python-dateutil==2.9.0.post0
      - rdflib==5.0.0
      - scipy==1.5.4
      - simplejson==3.20.1
      - six==1.17.0
      - tomli==1.2.3
      - traits==6.4.1
      - typing-extensions==4.1.1
      - zipp==3.6.0
prefix: /opt/conda/envs/nipype

nipype/interfaces/utility/tests/test_base.py::test_merge[args2-kwargs2-in_lists2-expected2] nipype/interfaces/utility/tests/test_base.py::test_merge[args3-kwargs3-in_lists3-expected3]
nipype/interfaces/utility/tests/test_base.py::test_rename nipype/interfaces/utility/tests/test_base.py::test_split[args0-expected0] nipype/interfaces/utility/tests/test_base.py::test_split[args1-expected1] nipype/interfaces/utility/tests/test_base.py::test_merge[args0-kwargs0-in_lists0-expected0] nipype/interfaces/utility/tests/test_base.py::test_merge[args1-kwargs1-None-None] nipype/interfaces/utility/tests/test_base.py::test_merge[args4-kwargs4-in_lists4-expected4] nipype/interfaces/utility/tests/test_base.py::test_merge[args5-kwargs5-in_lists5-expected5] nipype/interfaces/utility/tests/test_base.py::test_merge[args6-kwargs6-in_lists6-expected6]
nipype/interfaces/utility/base.py
nipype/interfaces/utility/base.py