[style] consistent nn. and nn.functional: part2: templates
Continuing https://github.com/huggingface/transformers/pull/12124 this PR takes care of `templates` - had to do some manual tweaking over automated rewrite here since `make fixup` can't process templates.

```
# deal with torch.nn
perl -pi -e 's|^import torch\n|from torch import nn\nimport torch\n|' `grep -Ilr torch.nn templates`
find templates -type f -exec perl -X -pi -e 's{(?<!(from |import |[`#/]))torch\.nn\.}{nn.}g' {} \;
find templates -type f -exec perl -pi -e 's|import torch\.nn as nn|from torch import nn|g' {} \;

# deal with F
find templates -type f -exec perl -pi -e 's|from torch.nn import functional as F|from torch import nn|g' {} \;
find templates -type f -exec perl -pi -e 's|import torch.nn.functional as F|from torch import nn|g' {} \;
find templates -type f -exec perl -pi -e 's|(?<!\w)F\.|nn.functional.|g' {} \;
make fixup
```
and some manual corrections to remove duplicated imports.

@sgugger 