Repository: Qiskit/qiskit (python)

Issue:
Parameter cache is preserved after copy_empty_like
### Environment

- **Qiskit version**: main
- **Python version**: 
- **Operating system**: 


### What is happening?

Parameter appears in empty circuit after copy

### How can we reproduce the issue?

```python
p1 = Parameter("P1")
qc = QuantumCircuit(1)
qc.rz(p1, 0)
qc.parameters  # dummy call to fill cache

cpy = qc.copy_empty_like()
cpy.parameters
```
I see
```
ParameterView([Parameter(P1)])
```
which should not exist.

### What should happen?

Parameter should be empty

### Any suggestions?

Nullify `_parameters` after copy

Pull request:
Invalidate `parameters` cache on circuit copy (backport #12619)
### Summary

Previously, the caching of the parameter view could persist between copies of the circuit because it was part of the `copy.copy`.




### Details and comments

Fix #12617.

I verified that this is present in 1.1.0 as well.<hr>This is an automatic backport of pull request #12619 done by [Mergify](https://mergify.com).

Patch:
diff --git a/qiskit/circuit/quantumcircuit.py b/qiskit/circuit/quantumcircuit.py
index 5d650f47c..3ff0394e0 100644
--- a/qiskit/circuit/quantumcircuit.py
+++ b/qiskit/circuit/quantumcircuit.py
@@ -3640,6 +3640,8 @@ class QuantumCircuit:
                 [(ParameterTable.GLOBAL_PHASE, None)]
             )
         cpy._data = CircuitData(self._data.qubits, self._data.clbits)
+        # Invalidate parameters caching.
+        cpy._parameters = None
 
         cpy._calibrations = _copy.deepcopy(self._calibrations)
         cpy._metadata = _copy.deepcopy(self._metadata)
diff --git a/releasenotes/notes/fix-parameter-cache-05eac2f24477ccb8.yaml b/releasenotes/notes/fix-parameter-cache-05eac2f24477ccb8.yaml
new file mode 100644
index 000000000..05ac75956
--- /dev/null
+++ b/releasenotes/notes/fix-parameter-cache-05eac2f24477ccb8.yaml
@@ -0,0 +1,7 @@
+---
+fixes:
+  - |
+    The :attr:`.QuantumCircuit.parameters` attribute will now correctly be empty
+    when using :meth:`.QuantumCircuit.copy_empty_like` on a parametric circuit.
+    Previously, an internal cache would be copied over without invalidation.
+    Fix `#12617 <https://github.com/Qiskit/qiskit/issues/12617>`__.


Test patch:
diff --git a/test/python/circuit/test_parameters.py b/test/python/circuit/test_parameters.py
index 2ac8aff61..2e2bd66cc 100644
--- a/test/python/circuit/test_parameters.py
+++ b/test/python/circuit/test_parameters.py
@@ -199,6 +199,29 @@ class TestParameters(QiskitTestCase):
         for i, vi in enumerate(v):
             self.assertEqual(vi, qc.parameters[i])
 
+    def test_parameters_property_independent_after_copy(self):
+        """Test that any `parameters` property caching is invalidated after a copy operation."""
+        a = Parameter("a")
+        b = Parameter("b")
+        c = Parameter("c")
+
+        qc1 = QuantumCircuit(1)
+        qc1.rz(a, 0)
+        self.assertEqual(set(qc1.parameters), {a})
+
+        qc2 = qc1.copy_empty_like()
+        self.assertEqual(set(qc2.parameters), set())
+
+        qc3 = qc1.copy()
+        self.assertEqual(set(qc3.parameters), {a})
+        qc3.rz(b, 0)
+        self.assertEqual(set(qc3.parameters), {a, b})
+        self.assertEqual(set(qc1.parameters), {a})
+
+        qc1.rz(c, 0)
+        self.assertEqual(set(qc1.parameters), {a, c})
+        self.assertEqual(set(qc3.parameters), {a, b})
+
     def test_get_parameter(self):
         """Test the `get_parameter` method."""
         x = Parameter("x")