Repository: pytorch
Issue: torch.nn.functional.linear fails for multi-dimensional bias from torch 1.12
Labels: module: nn,triaged,module: regression

### 🐛 Describe the bug

~As [docs](https://pytorch.org/docs/1.12/generated/torch.nn.functional.linear.html?highlight=linear#torch.nn.functional.linear) explains, `torch.nn.functional.linear` supports inputs of~

```
input: (*, in_features)
weight: (out_features, in_features)
bias: (*, out_features)
```

(UPD  9 July 2022: This is a never-documented behaviour  https://github.com/pytorch/pytorch/issues/80946#issuecomment-1178272323)

, but torch 1.12 seems to raise error for multi-dimensional inputs.

```python
>>> import torch.nn.functional as F
>>> import torch
>>> F.linear(torch.randn(2,3,5),torch.randn(7,5),torch.randn(2,3,7))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: expand(torch.FloatTensor{[2, 3, 7]}, size=[6, 7]): the number of sizes provided (2) must be greater or equal to the number of dimensions in the tensor (3)
```

With torch 1.11,
```python
>>> import torch.nn.functional as F
>>> import torch
>>> F.linear(torch.randn(2,3,5),torch.randn(7,5),torch.randn(2,3,7))
tensor([[[ 1.5270e+00, -1.6008e+00,  1.0397e+00, -1.7440e-01, -1.2764e+00,
           1.1950e-01, -1.8383e+00],
         [-3.3737e+00,  1.9518e+00,  8.4368e-01, -5.5560e+00,  6.5014e-01,
          -8.5247e-01, -3.3299e+00],
         [ 5.3961e-01,  1.1424e+00,  9.3576e-01,  3.1827e-01, -6.9256e-01,
           1.6097e+00,  7.8738e-01]],

        [[-6.2245e-01, -2.4926e+00, -1.8944e+00, -1.0425e+00,  2.6903e+00,
          -5.9798e+00, -4.5269e-03],
         [-6.0497e-01, -2.6881e+00, -1.4605e+00, -1.7330e+00,  1.9412e-01,
          -3.6541e+00, -1.1137e+00],
         [ 2.1674e+00, -5.5175e+00, -4.5325e+00,  5.0340e+00,  5.5341e-01,
          -4.4188e+00,  5.1751e-01]]])
```

### Versions

```
Collecting environment information...
PyTorch version: N/A
Is debug build: N/A
CUDA used to build PyTorch: N/A
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.4 LTS (x86_64)
GCC version: (Ubuntu 10.3.0-1ubuntu1~20.04) 10.3.0
Clang version: Could not collect
CMake version: version 3.22.2
Libc version: glibc-2.31

Python version: 3.8.10 (default, Mar 15 2022, 12:22:08)  [GCC 9.4.0] (64-bit runtime)
Python platform: Linux-5.4.0-100-generic-x86_64-with-glibc2.2.5
Is CUDA available: N/A
CUDA runtime version: Could not collect
GPU models and configuration: 
GPU 0: Tesla V100-SXM2-16GB
GPU 1: Tesla V100-SXM2-16GB
GPU 2: Tesla V100-SXM2-16GB
GPU 3: Tesla V100-SXM2-16GB
GPU 4: Tesla V100-SXM2-16GB
GPU 5: Tesla V100-SXM2-16GB
GPU 6: Tesla V100-SXM2-16GB
GPU 7: Tesla V100-SXM2-16GB

Nvidia driver version: 470.103.01
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.8.0.5
/usr/lib/x86_64-linux-gnu/libcudnn_adv_infer.so.8.0.5
/usr/lib/x86_64-linux-gnu/libcudnn_adv_train.so.8.0.5
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_infer.so.8.0.5
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_train.so.8.0.5
/usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8.0.5
/usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8.0.5
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: N/A

Versions of relevant libraries:
[pip3] numpy==1.18.4
[pip3] torch==1.12.0
[pip3] torchvision==0.13.0
[conda] Could not collect
```

cc @ezyang @gchanan @zou3519 @albanD @mruberry @jbschlosser @walterddr @kshitij12345 @saketh-are