Updated `backbone_config` docstrings and type annotations
Author: simonreise
Pull request: yes

# What does this PR do?

<!--
Congratulations! You've made it this far! You're not quite done yet though.

Once merged, your PR is going to appear in the release notes with the title you set, so make sure it's a great title that fully reflects the extent of your awesome contribution.

Then, please replace this with a description of the change and which issue is fixed (if applicable). Please also include relevant motivation and context. List any dependencies (if any) that are required for this change.

Once you're done, someone will review your PR shortly (see the section "Who can review?" below to tag some potential reviewers). They may suggest changes to make the code even better. If no one reviewed your PR after a week has passed, don't hesitate to post a new comment @-mentioning the same persons---sometimes notifications get lost.
-->

<!-- Remove if not applicable -->

Fixes #42911

I updated `backbone_config` docstrings to match the same pattern (`Union[dict, "PreTrainedConfig"]`, *optional*, defaults to `ModelConfig()`) and fix the wrongly named defaults.

I also changed type annotations to `Optional[Union[dict, PreTrainedConfig]]` at model configs that were already annotated. However, type annotations exist only in OneFormer, MaskFormer and Mask2Former. I can add type annotations to other configs too, if needed.

I also removed `Only used in case `is_hybrid` is `True` or in case you want to leverage the [`AutoBackbone`] API.` from DepthAnything-like models, because they do not have `is_hybrid` parameter, and it is probably an artifact that remained after copying docstring from DPT.

## Before submitting
- [x] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [x] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#create-a-pull-request),
      Pull Request section?
- [x] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case.
- [x] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [ ] Did you write any new necessary tests?


## Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@zucchini-nlp @yonigozlan @molbap

<!-- Your PR will be replied to more quickly if you can figure out the right person to tag with @

 If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**.
 Please tag fewer than 3 people.

Models:

- text models: @ArthurZucker @Cyrilvallez
- vision models: @yonigozlan @molbap
- audio models: @eustlb @ebezzam @vasqu
- multimodal models: @zucchini-nlp
- graph models: @clefourrier

Library:

- generate: @zucchini-nlp (visual-language models) or @gante (all others)
- continuous batching: @remi-or @ArthurZucker @McPatate
- pipelines: @Rocketknight1
- tokenizers: @ArthurZucker and @itazap
- trainer: @SunMarc
- attention: @vasqu @ArthurZucker @CyrilVallez
- model loading (from pretrained, etc): @CyrilVallez
- distributed: @3outeille @ArthurZucker
- CIs: @ydshieh

Integrations:

- ray/raytune: @richardliaw, @amogkam
- Big Model Inference: @SunMarc
- quantization: @SunMarc @MekkCyber
- kernels: @MekkCyber @drbh
- peft: @BenjaminBossan @githubnemo

Devices/Backends:

- AMD ROCm: @ivarflakstad
- Intel XPU: @IlyasMoutawwakil
- Ascend NPU: @ivarflakstad 

Documentation: @stevhliu

Research projects are not maintained and should be taken as is.

 -->


Comments:
**[For maintainers]** Suggested jobs to run (before merge)

run-slow: conditional_detr, d_fine, dab_detr, deformable_detr, depth_anything, detr, dpt, edgetam, grounding_dino, mask2former, maskformer, mm_grounding_dino, omdet_turbo, oneformer, prompt_depth_anything, rt_detr

And here is the code that I used to test if models can run (or at least initialize) with `PreTrainedConfig`:

<details>
  <summary>Code</summary>

```py
from transformers.image_utils import load_image
import transformers
import torch

# Load and process an image
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = load_image(url)
image_processor = transformers.SegformerImageProcessor()
image = image_processor(image, return_tensors="pt")

# Conditional DETR
backbone = transformers.SwinConfig(
    out_features=["stage1", "stage2", "stage3", "stage4"],
    image_size=512,
)
config = transformers.ConditionalDetrConfig(
    backbone_config=backbone,
    backbone=None,
    use_timm_backbone=False,
    use_pretrained_backbone=False,
)
model = transformers.ConditionalDetrModel(config)

# DFine
backbone = transformers.HGNetV2Config(
    depths=[3, 4, 6, 3],
    downsample_in_bottleneck=False,
    downsample_in_first_stage=False,
    embedding_size=32,
    image_size=512,
    hidden_sizes=[256, 512, 1024, 2048],
    out_features=["stage2", "stage3", "stage4"],
    out_indices=[2, 3, 4],
    stage_downsample=[False, True, True, True],
    stage_in_channels=[64, 128, 512, 1024],
    stage_kernel_size=[3, 3, 5, 5],
    stage_light_block=[False, False, True, True],
    stage_mid_channels=[64, 128, 256,512],
    stage_names=["stem", "stage1", "stage2", "stage3","stage4"],
    stage_num_blocks=[1, 2, 5, 2],
    stage_out_channels=[128, 512, 1024, 2048],
    stem_channels=[3, 32, 64],
)
config = transformers.DFineConfig(
    backbone_config=backbone,
    backbone=None,
    use_timm_backbone=False,
    use_pretrained_backbone=False,
    decoder_in_channels=[384, 384, 384],
    decoder_attention_heads=8,
    decoder_ffn_dim=1024,
    decoder_layers=6,
    decoder_n_points=[3, 6, 3],
    encoder_attention_heads=8,
    encoder_ffn_dim=2048,
    encoder_hidden_dim=384,
    encoder_in_channels=[512, 1024, 2048],
)
model = transformers.DFineModel(config)

# Deformable DETR
backbone = transformers.SwinConfig(
    out_features=["stage1", "stage2", "stage3", "stage4"],
    image_size=512,
)
config = transformers.DeformableDetrConfig(
    backbone_config=backbone,
    backbone=None,
    use_timm_backbone=False,
    use_pretrained_backbone=False,
)
model = transformers.DeformableDetrModel(config)

# Depth Anything
backbone = transformers.Dinov2Config(
    image_size=512,
    hidden_size=384,
    num_attention_heads=6,
    out_indices=[9, 10, 11, 12],
    apply_layernorm=True,
    reshape_hidden_states=False,
)
config = transformers.DepthAnythingConfig(
    backbone_config=backbone,
    backbone=None,
    use_timm_backbone=False,
    use_pretrained_backbone=False,
)
model = transformers.DepthAnythingForDepthEstimation(config)

# DETR
backbone = transformers.SwinConfig(
    out_features=["stage1", "stage2", "stage3", "stage4"],
    image_size=512,
)
config = transformers.DetrConfig(
    backbone_config=backbone,
    backbone=None,
    use_timm_backbone=False,
    use_pretrained_backbone=False,
)
model = transformers.DetrModel(config)

# DPT
backbone = transformers.SwinConfig(
    out_features=["stage2", "stage3", "stage4"],
    image_size=512,
)
config = transformers.DPTConfig(
    backbone_config=backbone,
    backbone=None,
    use_timm_backbone=False,
    use_pretrained_backbone=False,
    is_hybrid=True,
    image_size=512,
)
model = transformers.DPTModel(config)

# Mask2Former
backbone = transformers.SwinConfig(
    out_features=["stage1", "stage2", "stage3", "stage4"],
    image_size=512,
)
config = transformers.Mask2FormerConfig(
    backbone_config=backbone,
    backbone=None,
    use_timm_backbone=False,
    use_pretrained_backbone=False,
)
model = transformers.Mask2FormerModel(config)

# MaskFormer
backbone = transformers.SwinConfig(
    out_features=["stage1", "stage2", "stage3", "stage4"],
    image_size=512,
)
config = transformers.MaskFormerConfig(
    backbone_config=backbone,
    backbone=None,
    use_timm_backbone=False,
    use_pretrained_backbone=False,
)
model = transformers.MaskFormerModel(config)

# Prompt Depth Anything
backbone = transformers.Dinov2Config(
    image_size=512,
    hidden_size=384,
    num_attention_heads=6,
    out_indices=[9, 10, 11, 12],
    apply_layernorm=True,
    reshape_hidden_states=False,
)
config = transformers.PromptDepthAnythingConfig(
    backbone_config=backbone,
    backbone=None,
    use_timm_backbone=False,
    use_pretrained_backbone=False,
)
model = transformers.PromptDepthAnythingForDepthEstimation(config)

# RT DETR
backbone = transformers.RTDetrResNetConfig(
    image_size=512,
    num_channels=3,
    embedding_size=64,
    hidden_sizes=[256, 512, 1024, 2048],
    depths=[3, 4, 6, 3],
    layer_type="bottleneck",
    hidden_act="relu",
    downsample_in_first_stage=False,
    downsample_in_bottleneck=False,
    out_features=None,
    out_indices=[2, 3, 4],
)
config = transformers.RTDetrConfig(
    backbone_config=backbone,
    backbone=None,
    use_timm_backbone=False,
    use_pretrained_backbone=False,
)

# RT DETR V2
backbone = transformers.RTDetrResNetConfig(
    image_size=512,
    num_channels=3,
    embedding_size=64,
    hidden_sizes=[256, 512, 1024, 2048],
    depths=[3, 4, 6, 3],
    layer_type="bottleneck",
    hidden_act="relu",
    downsample_in_first_stage=False,
    downsample_in_bottleneck=False,
    out_features=None,
    out_indices=[2, 3, 4],
)
config = transformers.RTDetrV2Config(
    backbone_config=backbone,
    backbone=None,
    use_timm_backbone=False,
    use_pretrained_backbone=False,
)
model = transformers.RTDetrV2Model(config)

# SAM 2
backbone = transformers.Sam2HieraDetConfig()
config = transformers.Sam2VisionConfig(
    backbone_config=backbone,
    backbone=None,
    use_timm_backbone=False,
    use_pretrained_backbone=False,
)
model = transformers.Sam2VisionModel(config)
model = transformers.RTDetrModel(config)

# Table Transformer
backbone = transformers.SwinConfig(
    out_features=["stage1", "stage2", "stage3", "stage4"],
    image_size=512,
)
config = transformers.TableTransformerConfig(
    backbone_config=backbone,
    backbone=None,
    use_timm_backbone=False,
    use_pretrained_backbone=False,
)
model = transformers.TableTransformerModel(config)

# UperNet
backbone = transformers.SwinConfig(
    out_features=["stage1", "stage2", "stage3", "stage4"],
    image_size=512,
)
config = transformers.UperNetConfig(
    backbone_config=backbone,
    backbone=None,
    use_timm_backbone=False,
    use_pretrained_backbone=False,
)
model = transformers.UperNetForSemanticSegmentation(config)
model = model.eval()

# VitMatte
backbone = transformers.VitDetConfig(
    out_features=["stage4"],
    image_size=512,
    hidden_size=384,
)
config = transformers.VitMatteConfig(
    backbone_config=backbone,
    backbone=None,
    use_timm_backbone=False,
    use_pretrained_backbone=False,
)
model = transformers.VitMatteForImageMatting(config)

# VitPose
backbone = transformers.VitPoseBackboneConfig(
    out_indices=[4],
    image_size=[512, 512],
)
config = transformers.VitPoseConfig(
    backbone_config=backbone,
    backbone=None,
    use_timm_backbone=False,
    use_pretrained_backbone=False,
)
model = transformers.VitPoseForPoseEstimation(config)

# ZoeDepth
backbone = transformers.BeitConfig(
    num_hidden_layers=24,
    hidden_size=1024,
    intermediate_size=4096,
    num_attention_heads=16,
    use_relative_position_bias=True,
    reshape_hidden_states=False,
    out_features=["stage6", "stage12", "stage18", "stage24"],
    image_size=512,
)
config = transformers.ZoeDepthConfig(
    backbone_config=backbone,
    backbone=None,
    use_timm_backbone=False,
    use_pretrained_backbone=False,
)
model = transformers.ZoeDepthForDepthEstimation(config)

# EDGE TAM
backbone = transformers.SwinConfig(
    out_features=["stage1", "stage2", "stage3", "stage4"],
    image_size=512,
)
config = transformers.EdgeTamVisionConfig(
    backbone_config=backbone,
    backbone=None,
    use_timm_backbone=False,
    use_pretrained_backbone=False,
)
model = transformers.EdgeTamVisionModel(config)

# Grounding DINO
backbone = transformers.SwinConfig(
    out_features=["stage1", "stage2", "stage3", "stage4"],
    image_size=512,
)
config = transformers.GroundingDinoConfig(
    backbone_config=backbone,
    backbone=None,
    use_timm_backbone=False,
    use_pretrained_backbone=False,
)
model = transformers.GroundingDinoModel(config)

# MM Grounding DINO 
backbone = transformers.SwinConfig(
    out_features=["stage1", "stage2", "stage3", "stage4"],
    image_size=512,
)
config = transformers.MMGroundingDinoConfig(
    backbone_config=backbone,
    backbone=None,
    use_timm_backbone=False,
    use_pretrained_backbone=False,
)
model = transformers.MMGroundingDinoModel(config)

# OMDET Turbo
backbone = transformers.SwinConfig(
    out_features=["stage1", "stage2", "stage3", "stage4"],
    image_size=512,
)
config = transformers.OmDetTurboConfig(
    backbone_config=backbone,
    backbone=None,
    use_timm_backbone=False,
    use_pretrained_backbone=False,
)
model = transformers.OmDetTurboForObjectDetection(config)

# OneFormer
backbone = transformers.SwinConfig(
    out_features=["stage1", "stage2", "stage3", "stage4"],
    image_size=512,
)
config = transformers.OneFormerConfig(
    backbone_config=backbone,
    backbone=None,
    use_timm_backbone=False,
    use_pretrained_backbone=False,
)
model = transformers.OneFormerModel(config)

# SAM 3
backbone = transformers.Sam3ViTConfig()
config = transformers.Sam3VisionConfig(
    backbone_config=backbone,
    backbone=None,
    use_timm_backbone=False,
    use_pretrained_backbone=False,
)
model = transformers.Sam3VisionModel(config)

# TVP
backbone = transformers.ResNetConfig(
    out_features=["stage4"],
    image_size=512,
)
config = transformers.TvpConfig(
    backbone_config=backbone,
    backbone=None,
    use_timm_backbone=False,
    use_pretrained_backbone=False,
    type_vocab_size=2,
    max_img_size=512,
)
model = transformers.TvpModel(config)

# Test run model (does not work with most of multimodal models)
model(**image)
```

</details>

run-slow: conditional_detr, d_fine, dab_detr, deformable_detr, depth_anything, detr, dpt, edgetam, grounding_dino, mask2former, maskformer, mm_grounding_dino, omdet_turbo, oneformer, prompt_depth_anything, rt_detr

This comment contains `run-slow`, running the specified jobs: 

models: ["models/conditional_detr", "models/d_fine", "models/dab_detr", "models/deformable_detr", "models/depth_anything", "models/detr", "models/dpt", "models/edgetam", "models/grounding_dino", "models/mask2former", "models/maskformer", "models/mm_grounding_dino", "models/omdet_turbo", "models/oneformer", "models/prompt_depth_anything", "models/rt_detr"]
quantizations: []

The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_42927). All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

## CI Results
[Workflow Run ⚙️](https://github.com/huggingface/transformers/actions/runs/20346824231)

✅ No failing test specific to this PR 🎉 !