We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
workflow with iterables and cloned nodes fail when expanding iterables
### Summary
When running a workflow which includes a cloned node and iterables the workflow will fail when expanding the iterables because the id of the cloned node will be the same as the original one.

### Actual behavior
Will result in an error:
Traceback (most recent call last):

  File "<ipython-input-55-177d6eaeef2c>", line 27, in <module>
    workflow.run()

  File "/data/eaxfjord/anaconda2/lib/python2.7/site-packages/nipype/pipeline/engine/workflows.py", line 592, in run
    execgraph = generate_expanded_graph(deepcopy(flatgraph))

  File "/data/eaxfjord/anaconda2/lib/python2.7/site-packages/nipype/pipeline/engine/utils.py", line 1042, in generate_expanded_graph
    iterable_prefix, inode.synchronize)

  File "/data/eaxfjord/anaconda2/lib/python2.7/site-packages/nipype/pipeline/engine/utils.py", line 733, in _merge_graphs
    raise Exception(("Execution graph does not have a unique set of node "

Exception: Execution graph does not have a unique set of node names. Please rerun the workflow

### Expected behavior
Will execute normally without the errors.

### How to replicate the behavior
The following workflow will produce the error.

### Script/Workflow details
```python
from nipype.interfaces import utility as niu
from nipype.pipeline import engine as pe

def addstr(string):
    string = ('%s+2' % string )
    return string

subject_list = ['sub-001', 'sub-002']

inputnode = pe.Node(niu.IdentityInterface(fields = ['subject']),
                        name = 'inputnode')
inputnode.iterables = [('subject', subject_list)]

node_1 = pe.Node(niu.Function(input_names='string',
                              output_names= 'string',
                              function = addstr),name='node_1')
node_2 = node_1.clone('node_2')

workflow = pe.Workflow(name='my_workflow')
workflow.connect([(inputnode, node_1, [('subject','string')]),
                  (node_1, node_2, [('string','string')])])
workflow.run()
```
### Platform details:
/data/eaxfjord/anaconda2/lib/python2.7/site-packages/h5py/__init__.py:34: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
{'nibabel_version': '2.2.1', 'sys_executable': '/data/eaxfjord/anaconda2/bin/python', 'networkx_version': '2.1', 'numpy_version': '1.14.0', 'sys_platform': 'linux2', 'sys_version': '2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15) \n[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]', 'commit_source': 'installation', 'commit_hash': '0a5948a0', 'pkg_path': '/data/eaxfjord/anaconda2/lib/python2.7/site-packages/nipype', 'nipype_version': '1.0.0', 'traits_version': '4.6.0', 'scipy_version': '1.0.0'}
1.0.0


### Execution environment
- My python environment outside container


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `nipype/pipeline/engine/base.py`
Content:
```
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
4 # vi: set ft=python sts=4 ts=4 sw=4 et:
5 """Defines functionality for pipelined execution of interfaces
6 
7 The `EngineBase` class implements the more general view of a task.
8 
9   .. testsetup::
10      # Change directory to provide relative paths for doctests
11      import os
12      filepath = os.path.dirname(os.path.realpath( __file__ ))
13      datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
14      os.chdir(datadir)
15 
16 """
17 from __future__ import (print_function, division, unicode_literals,
18                         absolute_import)
19 from builtins import object
20 
21 from copy import deepcopy
22 import re
23 import numpy as np
24 
25 from ... import config
26 from ...interfaces.base import DynamicTraitedSpec
27 from ...utils.filemanip import loadpkl, savepkl
28 
29 
30 class EngineBase(object):
31     """Defines common attributes and functions for workflows and nodes."""
32 
33     def __init__(self, name=None, base_dir=None):
34         """ Initialize base parameters of a workflow or node
35 
36         Parameters
37         ----------
38         name : string (mandatory)
39             Name of this node. Name must be alphanumeric and not contain any
40             special characters (e.g., '.', '@').
41         base_dir : string
42             base output directory (will be hashed before creations)
43             default=None, which results in the use of mkdtemp
44 
45         """
46         self._hierarchy = None
47         self._name = None
48 
49         self.base_dir = base_dir
50         self.config = deepcopy(config._sections)
51         self.name = name
52 
53     @property
54     def name(self):
55         return self._name
56 
57     @name.setter
58     def name(self, name):
59         if not name or not re.match(r'^[\w-]+$', name):
60             raise ValueError('[Workflow|Node] name "%s" is not valid.' % name)
61         self._name = name
62 
63     @property
64     def fullname(self):
65         if self._hierarchy:
66             return '%s.%s' % (self._hierarchy, self.name)
67         return self.name
68 
69     @property
70     def inputs(self):
71         raise NotImplementedError
72 
73     @property
74     def outputs(self):
75         raise NotImplementedError
76 
77     def clone(self, name):
78         """Clone an EngineBase object
79 
80         Parameters
81         ----------
82 
83         name : string (mandatory)
84             A clone of node or workflow must have a new name
85         """
86         if name == self.name:
87             raise ValueError('Cloning requires a new name, "%s" is in use.' % name)
88         clone = deepcopy(self)
89         clone.name = name
90         return clone
91 
92     def _check_outputs(self, parameter):
93         return hasattr(self.outputs, parameter)
94 
95     def _check_inputs(self, parameter):
96         if isinstance(self.inputs, DynamicTraitedSpec):
97             return True
98         return hasattr(self.inputs, parameter)
99 
100     def __str__(self):
101         return self.fullname
102 
103     def save(self, filename=None):
104         if filename is None:
105             filename = 'temp.pklz'
106         savepkl(filename, self)
107 
108     def load(self, filename):
109         if '.npz' in filename:
110             DeprecationWarning(('npz files will be deprecated in the next '
111                                 'release. you can use numpy to open them.'))
112             return np.load(filename)
113         return loadpkl(filename)
114
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/nipype/pipeline/engine/base.py b/nipype/pipeline/engine/base.py
--- a/nipype/pipeline/engine/base.py
+++ b/nipype/pipeline/engine/base.py
@@ -84,9 +84,12 @@
             A clone of node or workflow must have a new name
         """
         if name == self.name:
-            raise ValueError('Cloning requires a new name, "%s" is in use.' % name)
+            raise ValueError('Cloning requires a new name, "%s" is '
+                             'in use.' % name)
         clone = deepcopy(self)
         clone.name = name
+        if hasattr(clone, '_id'):
+            clone._id = name
         return clone
 
     def _check_outputs(self, parameter):

{"golden_diff": "diff --git a/nipype/pipeline/engine/base.py b/nipype/pipeline/engine/base.py\n--- a/nipype/pipeline/engine/base.py\n+++ b/nipype/pipeline/engine/base.py\n@@ -84,9 +84,12 @@\n             A clone of node or workflow must have a new name\n         \"\"\"\n         if name == self.name:\n-            raise ValueError('Cloning requires a new name, \"%s\" is in use.' % name)\n+            raise ValueError('Cloning requires a new name, \"%s\" is '\n+                             'in use.' % name)\n         clone = deepcopy(self)\n         clone.name = name\n+        if hasattr(clone, '_id'):\n+            clone._id = name\n         return clone\n \n     def _check_outputs(self, parameter):\n", "issue": "workflow with iterables and cloned nodes fail when expanding iterables\n### Summary\r\nWhen running a workflow which includes a cloned node and iterables the workflow will fail when expanding the iterables because the id of the cloned node will be the same as the original one.\r\n\r\n### Actual behavior\r\nWill result in an error:\r\nTraceback (most recent call last):\r\n\r\n  File \"<ipython-input-55-177d6eaeef2c>\", line 27, in <module>\r\n    workflow.run()\r\n\r\n  File \"/data/eaxfjord/anaconda2/lib/python2.7/site-packages/nipype/pipeline/engine/workflows.py\", line 592, in run\r\n    execgraph = generate_expanded_graph(deepcopy(flatgraph))\r\n\r\n  File \"/data/eaxfjord/anaconda2/lib/python2.7/site-packages/nipype/pipeline/engine/utils.py\", line 1042, in generate_expanded_graph\r\n    iterable_prefix, inode.synchronize)\r\n\r\n  File \"/data/eaxfjord/anaconda2/lib/python2.7/site-packages/nipype/pipeline/engine/utils.py\", line 733, in _merge_graphs\r\n    raise Exception((\"Execution graph does not have a unique set of node \"\r\n\r\nException: Execution graph does not have a unique set of node names. Please rerun the workflow\r\n\r\n### Expected behavior\r\nWill execute normally without the errors.\r\n\r\n### How to replicate the behavior\r\nThe following workflow will produce the error.\r\n\r\n### Script/Workflow details\r\n```python\r\nfrom nipype.interfaces import utility as niu\r\nfrom nipype.pipeline import engine as pe\r\n\r\ndef addstr(string):\r\n    string = ('%s+2' % string )\r\n    return string\r\n\r\nsubject_list = ['sub-001', 'sub-002']\r\n\r\ninputnode = pe.Node(niu.IdentityInterface(fields = ['subject']),\r\n                        name = 'inputnode')\r\ninputnode.iterables = [('subject', subject_list)]\r\n\r\nnode_1 = pe.Node(niu.Function(input_names='string',\r\n                              output_names= 'string',\r\n                              function = addstr),name='node_1')\r\nnode_2 = node_1.clone('node_2')\r\n\r\nworkflow = pe.Workflow(name='my_workflow')\r\nworkflow.connect([(inputnode, node_1, [('subject','string')]),\r\n                  (node_1, node_2, [('string','string')])])\r\nworkflow.run()\r\n```\r\n### Platform details:\r\n/data/eaxfjord/anaconda2/lib/python2.7/site-packages/h5py/__init__.py:34: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.\r\n  from ._conv import register_converters as _register_converters\r\n{'nibabel_version': '2.2.1', 'sys_executable': '/data/eaxfjord/anaconda2/bin/python', 'networkx_version': '2.1', 'numpy_version': '1.14.0', 'sys_platform': 'linux2', 'sys_version': '2.7.13 |Anaconda custom (64-bit)| (default, Dec 20 2016, 23:09:15) \\n[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]', 'commit_source': 'installation', 'commit_hash': '0a5948a0', 'pkg_path': '/data/eaxfjord/anaconda2/lib/python2.7/site-packages/nipype', 'nipype_version': '1.0.0', 'traits_version': '4.6.0', 'scipy_version': '1.0.0'}\r\n1.0.0\r\n\r\n\r\n### Execution environment\r\n- My python environment outside container\r\n\n", "before_files": [{"content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-\n# vi: set ft=python sts=4 ts=4 sw=4 et:\n\"\"\"Defines functionality for pipelined execution of interfaces\n\nThe `EngineBase` class implements the more general view of a task.\n\n  .. testsetup::\n     # Change directory to provide relative paths for doctests\n     import os\n     filepath = os.path.dirname(os.path.realpath( __file__ ))\n     datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))\n     os.chdir(datadir)\n\n\"\"\"\nfrom __future__ import (print_function, division, unicode_literals,\n                        absolute_import)\nfrom builtins import object\n\nfrom copy import deepcopy\nimport re\nimport numpy as np\n\nfrom ... import config\nfrom ...interfaces.base import DynamicTraitedSpec\nfrom ...utils.filemanip import loadpkl, savepkl\n\n\nclass EngineBase(object):\n    \"\"\"Defines common attributes and functions for workflows and nodes.\"\"\"\n\n    def __init__(self, name=None, base_dir=None):\n        \"\"\" Initialize base parameters of a workflow or node\n\n        Parameters\n        ----------\n        name : string (mandatory)\n            Name of this node. Name must be alphanumeric and not contain any\n            special characters (e.g., '.', '@').\n        base_dir : string\n            base output directory (will be hashed before creations)\n            default=None, which results in the use of mkdtemp\n\n        \"\"\"\n        self._hierarchy = None\n        self._name = None\n\n        self.base_dir = base_dir\n        self.config = deepcopy(config._sections)\n        self.name = name\n\n    @property\n    def name(self):\n        return self._name\n\n    @name.setter\n    def name(self, name):\n        if not name or not re.match(r'^[\\w-]+$', name):\n            raise ValueError('[Workflow|Node] name \"%s\" is not valid.' % name)\n        self._name = name\n\n    @property\n    def fullname(self):\n        if self._hierarchy:\n            return '%s.%s' % (self._hierarchy, self.name)\n        return self.name\n\n    @property\n    def inputs(self):\n        raise NotImplementedError\n\n    @property\n    def outputs(self):\n        raise NotImplementedError\n\n    def clone(self, name):\n        \"\"\"Clone an EngineBase object\n\n        Parameters\n        ----------\n\n        name : string (mandatory)\n            A clone of node or workflow must have a new name\n        \"\"\"\n        if name == self.name:\n            raise ValueError('Cloning requires a new name, \"%s\" is in use.' % name)\n        clone = deepcopy(self)\n        clone.name = name\n        return clone\n\n    def _check_outputs(self, parameter):\n        return hasattr(self.outputs, parameter)\n\n    def _check_inputs(self, parameter):\n        if isinstance(self.inputs, DynamicTraitedSpec):\n            return True\n        return hasattr(self.inputs, parameter)\n\n    def __str__(self):\n        return self.fullname\n\n    def save(self, filename=None):\n        if filename is None:\n            filename = 'temp.pklz'\n        savepkl(filename, self)\n\n    def load(self, filename):\n        if '.npz' in filename:\n            DeprecationWarning(('npz files will be deprecated in the next '\n                                'release. you can use numpy to open them.'))\n            return np.load(filename)\n        return loadpkl(filename)\n", "path": "nipype/pipeline/engine/base.py"}], "after_files": [{"content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-\n# vi: set ft=python sts=4 ts=4 sw=4 et:\n\"\"\"Defines functionality for pipelined execution of interfaces\n\nThe `EngineBase` class implements the more general view of a task.\n\n  .. testsetup::\n     # Change directory to provide relative paths for doctests\n     import os\n     filepath = os.path.dirname(os.path.realpath( __file__ ))\n     datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))\n     os.chdir(datadir)\n\n\"\"\"\nfrom __future__ import (print_function, division, unicode_literals,\n                        absolute_import)\nfrom builtins import object\n\nfrom copy import deepcopy\nimport re\nimport numpy as np\n\nfrom ... import config\nfrom ...interfaces.base import DynamicTraitedSpec\nfrom ...utils.filemanip import loadpkl, savepkl\n\n\nclass EngineBase(object):\n    \"\"\"Defines common attributes and functions for workflows and nodes.\"\"\"\n\n    def __init__(self, name=None, base_dir=None):\n        \"\"\" Initialize base parameters of a workflow or node\n\n        Parameters\n        ----------\n        name : string (mandatory)\n            Name of this node. Name must be alphanumeric and not contain any\n            special characters (e.g., '.', '@').\n        base_dir : string\n            base output directory (will be hashed before creations)\n            default=None, which results in the use of mkdtemp\n\n        \"\"\"\n        self._hierarchy = None\n        self._name = None\n\n        self.base_dir = base_dir\n        self.config = deepcopy(config._sections)\n        self.name = name\n\n    @property\n    def name(self):\n        return self._name\n\n    @name.setter\n    def name(self, name):\n        if not name or not re.match(r'^[\\w-]+$', name):\n            raise ValueError('[Workflow|Node] name \"%s\" is not valid.' % name)\n        self._name = name\n\n    @property\n    def fullname(self):\n        if self._hierarchy:\n            return '%s.%s' % (self._hierarchy, self.name)\n        return self.name\n\n    @property\n    def inputs(self):\n        raise NotImplementedError\n\n    @property\n    def outputs(self):\n        raise NotImplementedError\n\n    def clone(self, name):\n        \"\"\"Clone an EngineBase object\n\n        Parameters\n        ----------\n\n        name : string (mandatory)\n            A clone of node or workflow must have a new name\n        \"\"\"\n        if name == self.name:\n            raise ValueError('Cloning requires a new name, \"%s\" is '\n                             'in use.' % name)\n        clone = deepcopy(self)\n        clone.name = name\n        if hasattr(clone, '_id'):\n            clone._id = name\n        return clone\n\n    def _check_outputs(self, parameter):\n        return hasattr(self.outputs, parameter)\n\n    def _check_inputs(self, parameter):\n        if isinstance(self.inputs, DynamicTraitedSpec):\n            return True\n        return hasattr(self.inputs, parameter)\n\n    def __str__(self):\n        return self.fullname\n\n    def save(self, filename=None):\n        if filename is None:\n            filename = 'temp.pklz'\n        savepkl(filename, self)\n\n    def load(self, filename):\n        if '.npz' in filename:\n            DeprecationWarning(('npz files will be deprecated in the next '\n                                'release. you can use numpy to open them.'))\n            return np.load(filename)\n        return loadpkl(filename)\n", "path": "nipype/pipeline/engine/base.py"}]}