Could do
```
xi = xi.reshape(-1, shape[-1]) 
```