Repository: Qiskit/qiskit-terra (python)

Issue:
QuasiDistribution returned by BackendSampler has incorrect shots
### Environment

- **Qiskit Terra version**: 07e0a2fc79bada7c1fbf0594f4ad33934f70b7e
- **Python version**: 3.10.8
- **Operating system**: Arch Linux


### What is happening?

See title.

### How can we reproduce the issue?

```python
from qiskit.circuit import QuantumCircuit
from qiskit.primitives import BackendSampler
from qiskit.providers.fake_provider import FakeLagos

circuit = QuantumCircuit(2)
circuit.measure_all()

backend = FakeLagos()
sampler = BackendSampler(backend)
result = sampler.run(circuit, shots=100).result()
quasis = result.quasi_dists[0]
print(quasis.shots)
```
```
None
```

### What should happen?

It should print "100", not "None".

### Any suggestions?

_No response_

Pull request:
Make BackendSampler set shots and stddev_upper_bound of returned QuasiDistribution
<!--
⚠️ If you do not respect this template, your pull request will be closed.
⚠️ Your pull request title should be short detailed and understandable for all.
⚠️ Also, please add a release note file using reno if the change needs to be
  documented in the release notes.
⚠️ If your pull request fixes an open issue, please link to the issue.

- [ ] I have added the tests to cover my changes.
- [ ] I have updated the documentation accordingly.
- [ ] I have read the CONTRIBUTING document.
-->

### Summary
Fixes #9311 


### Details and comments




Patch:
diff --git a/qiskit/primitives/backend_sampler.py b/qiskit/primitives/backend_sampler.py
index 60d45f3af..241e79ede 100644
--- a/qiskit/primitives/backend_sampler.py
+++ b/qiskit/primitives/backend_sampler.py
@@ -14,6 +14,7 @@
 
 from __future__ import annotations
 
+import math
 from collections.abc import Sequence
 from typing import Any, cast
 
@@ -162,14 +163,16 @@ class BackendSampler(BaseSampler):
         counts = _prepare_counts(result)
         shots = sum(counts[0].values())
 
-        probabilies = []
+        probabilities = []
         metadata: list[dict[str, Any]] = [{}] * len(circuits)
         for count in counts:
             prob_dist = {k: v / shots for k, v in count.int_outcomes().items()}
-            probabilies.append(QuasiDistribution(prob_dist))
+            probabilities.append(
+                QuasiDistribution(prob_dist, shots=shots, stddev_upper_bound=math.sqrt(1 / shots))
+            )
             for metadatum in metadata:
                 metadatum["shots"] = shots
-        return SamplerResult(probabilies, metadata)
+        return SamplerResult(probabilities, metadata)
 
     def _transpile(self):
         from qiskit.compiler import transpile
diff --git a/releasenotes/notes/backend-sampler-shots-c233d5a3965e0c11.yaml b/releasenotes/notes/backend-sampler-shots-c233d5a3965e0c11.yaml
new file mode 100644
index 000000000..e5d16395e
--- /dev/null
+++ b/releasenotes/notes/backend-sampler-shots-c233d5a3965e0c11.yaml
@@ -0,0 +1,6 @@
+---
+features:
+  - |
+    :class:`~.BackendSampler` now sets the ``shots``
+    and ``stddev_upper_bound`` attributes of the returned :class:`~.QuasiDistribution`.
+    Previously it did not.
\ No newline at end of file


Test patch:
diff --git a/test/python/primitives/test_backend_sampler.py b/test/python/primitives/test_backend_sampler.py
index ef3172eab..e3816bf62 100644
--- a/test/python/primitives/test_backend_sampler.py
+++ b/test/python/primitives/test_backend_sampler.py
@@ -12,6 +12,7 @@
 
 """Tests for BackendSampler."""
 
+import math
 import unittest
 from test import combine
 
@@ -96,11 +97,12 @@ class TestBackendSampler(QiskitTestCase):
         """Test Sampler.run()."""
         bell = self._circuit[1]
         sampler = BackendSampler(backend=backend)
-        job = sampler.run(circuits=[bell])
+        job = sampler.run(circuits=[bell], shots=1000)
         self.assertIsInstance(job, JobV1)
         result = job.result()
         self.assertIsInstance(result, SamplerResult)
-        # print([q.binary_probabilities() for q in result.quasi_dists])
+        self.assertEqual(result.quasi_dists[0].shots, 1000)
+        self.assertEqual(result.quasi_dists[0].stddev_upper_bound, math.sqrt(1 / 1000))
         self._compare_probs(result.quasi_dists, self._target[1])
 
     @combine(backend=BACKENDS)