Repository: Qiskit/qiskit

Issue:
Casablanca backend:  UnboundLocalError: local variable 'grid_data' referenced before assignment
<!-- ⚠️ If you do not respect this template, your issue will be closed -->
<!-- ⚠️ Make sure to browse the opened and closed issues -->

### Information

- **Qiskit Terra version**: 'qiskit-terra': '0.16.0'
- **Python version**: 3.7.8
- **Operating system**: IBM Q experience

### What is the current behavior?
When one assigns the ibmq_Casablanca backend and calls the instruction `backend` to take a look at the properties, in the error map tab one gets

```
---------------------------------------------------------------------------
UnboundLocalError                         Traceback (most recent call last)
/opt/conda/lib/python3.7/site-packages/qiskit/tools/jupyter/backend_monitor.py in detailed_map(backend)
    435                                                         align_items='center'))
    436     with error_widget:
--> 437         display(plot_error_map(backend, figsize=(11, 9), show_title=False))
    438     return error_widget
    439 

/opt/conda/lib/python3.7/site-packages/qiskit/visualization/gate_map.py in plot_error_map(backend, figsize, show_title)
    516                   line_width=5,
    517                   plot_directed=directed,
--> 518                   ax=main_ax)
    519     main_ax.axis('off')
    520     main_ax.set_aspect(1)

/opt/conda/lib/python3.7/site-packages/qiskit/visualization/gate_map.py in plot_gate_map(backend, figsize, plot_directed, label_qubits, qubit_size, line_width, font_size, qubit_color, qubit_labels, line_color, font_color, ax)
    213             return fig
    214 
--> 215     x_max = max([d[1] for d in grid_data])
    216     y_max = max([d[0] for d in grid_data])
    217     max_dim = max(x_max, y_max)

UnboundLocalError: local variable 'grid_data' referenced before assignment
```


### Steps to reproduce the problem
In an IBM Q jupyter notebook execute first
```
%matplotlib inline
# Importing standard Qiskit libraries and configuring account
from qiskit import QuantumCircuit, execute, Aer, IBMQ
from qiskit.compiler import transpile, assemble
from qiskit.tools.jupyter import *
from qiskit.visualization import *
# Loading your IBM Q account(s)
provider = IBMQ.get_provider(hub='ibm-q-research', group='Your_name', project='main') 
```
Then, set up the backend, and call it
```
backend = provider.backends(name = 'ibmq_casablanca')[0]
backend
```

### What is the expected behavior?
A graph of the error map.


### Suggested solutions
It is unclear to me correct it. It might be the case that the background information is incomplete




Discussion:
Actually, I'm quite sure this might be related to [this other issue](https://github.com/Qiskit/qiskit-terra/issues/5296), marked as an enhancement.
Can confirm this is also an issue for me. Looking at the implementation of `plot_gate_map` it seems layouts for a set number of qubits are hardcoded.

Resolving patch:
diff --git a/qiskit/visualization/gate_map.py b/qiskit/visualization/gate_map.py
--- a/qiskit/visualization/gate_map.py
+++ b/qiskit/visualization/gate_map.py
@@ -132,6 +132,12 @@ def plot_gate_map(backend, figsize=None,
 
     mpl_data[1] = [[0, 0]]
 
+    mpl_data[5] = [[1, 0], [0, 1], [1, 1], [1, 2], [2, 1]]
+
+    mpl_data[7] = [[0, 0], [0, 1], [0, 2],
+                   [1, 1],
+                   [2, 0], [2, 1], [2, 2]]
+
     mpl_data[20] = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4],
                     [1, 0], [1, 1], [1, 2], [1, 3], [1, 4],
                     [2, 0], [2, 1], [2, 2], [2, 3], [2, 4],
@@ -145,8 +151,6 @@ def plot_gate_map(backend, figsize=None,
                     [0, 4], [0, 5], [0, 6], [0, 7], [1, 7],
                     [1, 6], [1, 5], [1, 4], [1, 3], [1, 2], [1, 1]]
 
-    mpl_data[5] = [[1, 0], [0, 1], [1, 1], [1, 2], [2, 1]]
-
     mpl_data[27] = [[1, 0], [1, 1], [2, 1], [3, 1], [1, 2],
                     [3, 2], [0, 3], [1, 3], [3, 3], [4, 3],
                     [1, 4], [3, 4], [1, 5], [2, 5], [3, 5],


Test patch: