text: 
  
  TITLE
  Switch `return_dict` to `True` by default.
  
  COMMENTS
  2
  
  REACTIONS
  +1: 0
  -1: 0
  laugh: 0
  hooray: 0
  heart: 0
  rocket: 0
  eyes: 0
  
  BODY
  # What does this PR do?
  
  As part of the main changes we want to bring to Transformers v4, this PR switches the `return_dict` argument default from `False` to `True`. Most of the examples and documentation were already using this value (the PR removes `return_dict=True` in all those instances since this is now the default).
  
  **New model outputs**
  
  The new model outputs are dictionaries (instead of tuples) with a bit of added functionality: you can access elements by their keys, as attributes or even by index (to keep most of the backward compatibility). Here is an example:
  
  ```python
  from transformers import BertTokenizer, BertForSequenceClassification
  import torch
  
  tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')
  model = BertForSequenceClassification.from_pretrained('bert-base-uncased')
  
  inputs = tokenizer("Hello, my dog is cute", return_tensors="pt")
  labels = torch.tensor([1]).unsqueeze(0)  # Batch size 1
  outputs = model(**inputs, labels=labels)
  ```
  
  The `outputs` object contains loss and logits and you can access them as keys:
  ```python
  loss = outputs["loss"]
  logits = outputs["logits"]
  ```
  or as attributes.
  ```python
  loss = outputs.loss
  logits = outputs.logits
  ```
  In an IDE you can thus use autocomplete to help.
  
  You can still index with integers or a slice:
  ```python
  loss = outputs[0]
  logits = outputs[1]
  loss, logits = outputs[:2]
  ```
  but you can't unpack the tuple directly as was done before:
  ```python
  loss, logits = outputs
  ```
  will return "loss" and "logits" in `loss` and `logits` (like dictionaries).
  
  **Known caveats**
  
  Torchscript is incompatible with dict outputs (until 1.7) so doesn't work with those new outputs. The flag `return_dict` will default to `False` if you use `torchscript=True` when building your model.
  
  TF Saved models deal with dictionaries but not their subclasses, so if you save and load your model using `tf.keras.models.load_model`, it will output regular dictionaries. This means that you won't be able to index in the outputs with integers or attributes, only their string keys.
  
  ```python
  tf.saved_model.save(model, tmpdirname)
  model = tf.keras.models.load_model(tmpdirname)
  outputs = model(inputs)
  loss = outputs["loss"]
  logits = outputs["logits"]
  ```
  
  Apex used in optimization mode "O2" will also lose the output types of the model and return regular dictionaries. This means that you won't be able to index in the outputs with integers or attributes, only their string keys.
  
  **Breaking change**
  
  All code of the form
  ```python
  loss, output = model(**inputs)
  ``` 
  needs to be switched to
  ```python
  loss, output = model(**inputs).to_tuple()
  ``` 
  or use the key/attributes of the model output returned.
  
  Alternatively, you can pass `return_dict=False` when creating your model to get regular tuples as outputs.