How can I introspect the input and output keys for an arbitrary model?

I managed to introspect the input keys that a model expects by checking model.dummy_inputs dict (do all models define this reliably? is there a better way?)

But I am currently struggling to find a way to determine the output keys.

The distilbert model I am experimenting with returns "logits", but I understand that not all models may output that key? And also there are config flags (e.g. model.config.output_hidden_states) that would cause additional keys to be output.

I’m not sure if this is specifically a transformers question or a PyTorch question…

Related… is there a way to introspect which models will need to use the from_pretrained(trust_remote_code=True) option when using AutoModelFrom* ?

(I mean other than just trying to load it without the flag and get an error and then trying again with it)