Create and Expose SamVisionModel as public for better accessibility
Author: geetu040
Pull request: yes

# What does this PR do?

This PR makes `SamVisionEncoder` publicly accessible while keeping its name unchanged. This improves usability by allowing users to instantiate the vision encoder directly, similar to how `SamModel` is used.

```py
from transformers import SamVisionConfig, SamVisionEncoder
config = SamVisionConfig()
model = SamVisionEncoder(config)
```

Previously discussed here: https://github.com/huggingface/transformers/pull/36248#issuecomment-2677432503

## Before submitting
- [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).
- [x] Did you write any new necessary tests?

## Who can review?

@amyeroberts, @qubvel, @zucchini-nlp 

Comments:
Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. When it is ready for review, please click the `Ready for review` button (at the bottom of the PR page).

Hi @qubvel and @zucchini-nlp 

I have updated `SamVisionEncoder` to make it public, but I am having a problem making `TFSamVisionEncoder` public.

First, I am not even sure, if it is necessary to have `TFSamVisionEncoder` public, I am just following the test `utils/check_repo.py` which fails to find `TFSamVisionEncoder`

`TFSamVisionEncoder` saves the vision layers in attribute `self.layers`, this works fine when `TFSamVisionEncoder` inherits from `keras.layers.Layer` but fails when inherited from `TFPreTrainedModel` which inherits from `keras.models.Model`. Because `keras.models.Model` already has `layers` as a read-only-property.

Changing the name would break backward compatibility, we can either:
1. completely disregard the idea of making SamVisionEncoder public and use modular where it is needed as backbone (in context of Deepseek-VL [#36248](https://github.com/huggingface/transformers/pull/36248#issuecomment-2677432503)).
2. make `SamVisionEncoder` public and leave `TFSamVisionEncoder` as it as, and exempt this from relevant tests.

@zucchini-nlp

I have added `TFSamVisionEncoder` to `__init__`, that fixes the [failing check](https://circleci.com/gh/huggingface/transformers/1626533).

Though `TFSamVisionEncoder` still doesnot inherit `TFSamPreTrainedModel` and therefore is not added to auto modeling.
Fails to inherit because https://github.com/huggingface/transformers/pull/36493#issuecomment-2692621159
> `TFSamVisionEncoder` saves the vision layers in attribute `self.layers`, this works fine when `TFSamVisionEncoder` inherits from `keras.layers.Layer` but fails when inherited from `TFPreTrainedModel` which inherits from `keras.models.Model`. Because `keras.models.Model` already has `layers` as a read-only-property.

---

And by the way `SamVisionEncoder` works all fine. To conclude everything:

`SamVisionEncoder`
- [x] imported in `__init__`, available via `from transformers import SamVisionEncoder`
- [x] part of auto modeling
- [x] imports PreTrainedModel
- [x] available in docs

`TFSamVisionEncoder`
- [x] imported in `__init__`, available via `from transformers import TFSamVisionEncoder`
- [ ] not part of auto modeling
- [ ] doesnot import PreTrainedModel
- [ ] not available in docs

The failing checks at [ci/circleci: tests_torch]() are fixed in https://github.com/huggingface/transformers/pull/36422.

@zucchini-nlp all the problems are solved. Now  both torch and tensorflow versions of `SamVisionEncoder` are public.

I realized what I said in the above comment https://github.com/huggingface/transformers/pull/36493#issuecomment-2695964717 was not really a problem.

<details>
<summary> Here is the explanation if you are interested </summary>

We cannot use `self.layers` in `keras.Model` to save parameters but we don't necessarily have to call it `self.layers` inorder to ensure that the weights are given the right keys.
```py
class CustomModel(tf.keras.Model):
    def __init__(self):
        super().__init__()
        self.dense = tf.keras.layers.Dense(10, name="layer")

    def call(self, x)
        return self.dense(x)
```
In this case, unlike torch, the weights for Dense layer are assosiated with the key "layer" instead of "dense"

</details>

---

All the tests are passing, the 2 failing ones are fixed in https://github.com/huggingface/transformers/pull/36422
I also ran tests by merging the 2 branches in this [colab notebook](https://colab.research.google.com/drive/18dHgDaaU8VaJAzfxR2gY-g0EFp9m-Pw0#scrollTo=RjoDA6CBpU0W) and they are all passing.


> Also I see `test_attention_outputs` is failing for Sam Models currently, can you take a look at that?

They fail because of the `SamVisionSdpaAttention` which is fixed in https://github.com/huggingface/transformers/pull/36422

@geetu040 can you rebase `main`, the blocker was merged already! I request review from qubvel, so we don't wait for core maintainer and unblock your for DeekSeek

@qubvel
`SamVisionModel` added alongside `SamVisionEncoder`

ping @qubvel for review

Hello @qubvel, a soft reminder for review

Thanks for the ping @geetu040, will review today