docs: Fixed variables in f-strings
# What does this PR do?

Fixes unknown variables in some documentation code blocks' f-strings.

- [x] This PR fixes a typo or improves the docs

## In addition...
The following code block, which can be found at https://huggingface.co/docs/transformers/custom_models#writing-a-custom-model & [custom_models.mdx](https://github.com/huggingface/transformers/blob/main/docs/source/en/custom_models.mdx), uses `torch` without `import torch` being performed in any prior docstring.

```python
class ResnetModelForImageClassification(PreTrainedModel):
    config_class = ResnetConfig

    def __init__(self, config):
        super().__init__(config)
        block_layer = BLOCK_MAPPING[config.block_type]
        self.model = ResNet(
            block_layer,
            config.layers,
            num_classes=config.num_classes,
            in_chans=config.input_channels,
            cardinality=config.cardinality,
            base_width=config.base_width,
            stem_width=config.stem_width,
            stem_type=config.stem_type,
            avg_down=config.avg_down,
        )

    def forward(self, tensor, labels=None):
        logits = self.model(tensor)
        if labels is not None:
            loss = torch.nn.cross_entropy(logits, labels)
            return {"loss": loss, "logits": logits}
        return {"logits": logits}
```
If preferred, I can add `import torch` in this code block in this PR, or make a new one for it.

## Who can review?

Documentation: @sgugger

- Tom Aarsen
_The documentation is not available anymore as the PR was closed or merged._<|||||>Done & done!<|||||>Thanks again for your contribution!