Adding a repr to pipelines
Author: payoto
Pull request: no

### Feature request

Would you be interested in adding a `__repr__` to the `Pipeline` class?

### Motivation

This could be used to display useful information after instantiation, particularly in interactive environments like Jupyter. A useful representation would be very useful to display what defaults were loaded by a library or model.

### Your contribution

I've been testing in my local install and I can submit a PR with the following:

```python
class Pipeline(_ScikitCompat):
    ...
    def __repr__(self) -> str:
        string_out = (
            f"{type(self).__name__}(\n"
            f"    task={self.task},\n"
            f"    modelcard={self.modelcard},\n"
            f"    feature_extractor={self.feature_extractor},\n"
            f"    framework={self.framework},\n"
            f"    device={self.device},\n"
            f"    call_count={self.call_count},\n"
            f"    tokenizer={self.tokenizer},\n"
            f"    model.config={self.model.config},\n"
            ")"
        )
        return string_out
```

Which has output:

```python
TextClassificationPipeline(
    task=text-classification,
    modelcard=None,
    feature_extractor=None,
    framework=pt,
    device=cpu,
    call_count=3,
    tokenizer=PreTrainedTokenizerFast(name_or_path='nlptown/bert-base-multilingual-uncased-sentiment', vocab_size=105879, model_max_len=512, is_fast=True, padding_side='right', truncation_side='right', special_tokens={'unk_token': '[UNK]', 'sep_token': '[SEP]', 'pad_token': '[PAD]', 'cls_token': '[CLS]', 'mask_token': '[MASK]'}),
    model.config=BertConfig {
  "_name_or_path": "nlptown/bert-base-multilingual-uncased-sentiment",
  "_num_labels": 5,
  "architectures": [
    "BertForSequenceClassification"
  ],
  "attention_probs_dropout_prob": 0.1,
  "classifier_dropout": null,
  "directionality": "bidi",
  "finetuning_task": "sentiment-analysis",
  "hidden_act": "gelu",
  "hidden_dropout_prob": 0.1,
  "hidden_size": 768,
  "id2label": {
    "0": "1 star",
    "1": "2 stars",
    "2": "3 stars",
    "3": "4 stars",
    "4": "5 stars"
  },
  "initializer_range": 0.02,
  "intermediate_size": 3072,
  "label2id": {
    "1 star": 0,
    "2 stars": 1,
    "3 stars": 2,
    "4 stars": 3,
    "5 stars": 4
  },
  "layer_norm_eps": 1e-12,
  "max_position_embeddings": 512,
  "model_type": "bert",
  "num_attention_heads": 12,
  "num_hidden_layers": 12,
  "output_past": true,
  "pad_token_id": 0,
  "pooler_fc_size": 768,
  "pooler_num_attention_heads": 12,
  "pooler_num_fc_layers": 3,
  "pooler_size_per_head": 128,
  "pooler_type": "first_token_transform",
  "position_embedding_type": "absolute",
  "transformers_version": "4.20.1",
  "type_vocab_size": 2,
  "use_cache": true,
  "vocab_size": 105879
}
,
)
```

Comments:
cc @Narsil 

@payoto ,

This seems like a good idea ! 

I'm slightly worried about the size of the `repr` though. It's already really large with your example, and you are missing the extra `_{preprocess,forward,postprocess}_params`. (Which are important imo)

As a start, I would use exactly what you have done, but only without the config. 
For the `model` I would actually put it, but maybe only the class names bcause `repr(model)` is also quite verbose.

The reason I added the `model.config` entry was that it showed me information about the expected output of the pipeline, one of the things I wanted to find out was "what are all the possible classes returned by this pipeline"? Where would you recommend I get that information?

I'll open a PR with what you've suggested, and we can iterate from there.

> what are all the possible classes returned by this pipeline"?

You mean `config.id2label` ? I sympathize with the goal, but `repr` is meant to be seen by devs easily during iteration, so making them short is important IMO. But we can start with your version if you prefer and we'll adapt based on community feedback.
Your proposal is already much better than the current state !

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.