[WIP] Add model hiera
Author: Namangarg110
Pull request: yes
Labels: name: New model

# What does this PR do?

This PR adds Hiera by Meta to Transformers. Model details mentioned below.

Model description
Hiera is a hierarchical vision transformer that is fast, powerful, and, above all, simple. It outperforms the state-of-the-art across a wide array of image and video tasks while being much faster.

GitHub Repo: https://github.com/facebookresearch/hiera/ (but licensed under CC BY-NC 4.0)
arXiv: https://arxiv.org/abs/2306.00989

This was discussed in issue: https://github.com/huggingface/transformers/issues/28993

## My Comments

I am still working on model's tests 

## Before submitting
- [ ] 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.

@amyeroberts @stevhliu @MKhalusova


Comments:
@Namangarg110 Awesome! Let us know when it's ready for review 🤗 

Hii @amyeroberts,
The code is ready for review. All test cases are running locally. However, there is a problem with the way I am importing things. I would really appreciate if you could guide me.

Best,
Naman 

```

  File "utils/check_inits.py", line 370, in <module>
    check_all_inits()
  File "utils/check_inits.py", line 298, in check_all_inits
    raise ValueError("\n\n".join(failures))
ValueError: Problem in src/transformers/__init__.py, both halves do not define the same objects.
Differences for torch backend:
  HIERA_PRETRAINED_MODEL_ARCHIVE_LIST in TYPE_HINT but not in _import_structure.
  HieraModel in TYPE_HINT but not in _import_structure.
  HieraPreTrainedModel in TYPE_HINT but not in _import_structure.
Differences for tf backend:
  HIERA_PRETRAINED_MODEL_ARCHIVE_LIST in _import_structure but not in TYPE_HINT.
  HieraModel in _import_structure but not in TYPE_HINT.
  HieraPreTrainedModel in _import_structure but not in TYPE_HINT.

Problem in src/transformers/models/hiera/__init__.py, both halves do not define the same objects.
Differences for torch backend:
  HIERA_PRETRAINED_MODEL_ARCHIVE_LIST, in TYPE_HINT but not in _import_structure.
  HieraModel, in TYPE_HINT but not in _import_structure.
   in TYPE_HINT but not in _import_structure.
  HIERA_PRETRAINED_MODEL_ARCHIVE_LIST in _import_structure but not in TYPE_HINT.
  HieraModel in _import_structure but not in TYPE_HINT.

Exited with code exit status 1
```

> Great work! I did a first pass over the documentation and made some suggestions 🙂

Thankyou @stevhliu for swift response. I have fixed all the suggested changes and some additional similar changes 

Thankyou for clarification @amyeroberts. Please let me know once you've had a chance to review the code.

> I've just done a first high-level overview. After the larger structural points are addressed I'll review more deeply.

Thank you for your review, @amyeroberts. Apologies for the delayed response—I'm currently in the midst of finals week. I'll aim to address all the issues as soon as possible.

I'm truly sorry for the delay.

@Namangarg110 No worries - thanks for letting us know. Best of luck with your finals! 

@amyeroberts Sorry for the unexpected delay. The code is ready for review 

> @amyeroberts Sorry for the unexpected delay. The code is ready for review

Hey @Namangarg110, I've taken a look at your PR and it seems to me that there are still things that are not in the library standards (though Amy can confirm later).

Not sure, if you saw, but I've started a PR of my own here https://github.com/huggingface/transformers/pull/29945 and I'd say, from past experience, that the state of my PR is closer to merge. 

If you want to I'd appreciate your help with a few things that are still missing like finishing the `HieraForMaskedImageModeling` and `HieraBackbone`. 

We could merge our branches to have the commit history, let me know what you think and we can talk specifics on how to proceed 😄 

> > @amyeroberts Sorry for the unexpected delay. The code is ready for review
> 
> Hey @Namangarg110, I've taken a look at your PR and it seems to me that there are still things that are not in the library standards (though Amy can confirm later).
> 
> Not sure, if you saw, but I've started a PR of my own here #29945 and I'd say, from past experience, that the state of my PR is closer to merge.
> 
> If you want to I'd appreciate your help with a few things that are still missing like finishing the `HieraForMaskedImageModeling` and `HieraBackbone`.
> 
> We could merge our branches to have the commit history, let me know what you think and we can talk specifics on how to proceed 😄

Hii @EduardoPach ,
Thankyou for reaching out. I understand that your PR more closely aligns with transformers. However, this is my first open-source contribution so I am working on my repository iteratively. and I want to try to complete it by myself. 

But, incase @amyeroberts feels like this won't work out or it's better for us to work together. I'd be down to talking about it.

I have already submitted my code for review. I am sure there would be many things that still needs improvement. 

What are your thoughts on the same @amyeroberts?

Best Regards,
Naman Garg

Hii @amyeroberts ,

Writing to follow up my previous comment and to check the status of the review.


@Namangarg110 @EduardoPach Thanks both for your interest in adding this model. 

As this PR was opened first and active (aside from a communicated break) this PR takes precedence. We do want models to be merged in as fast as possible and as @EduardoPach mentions, his PR is closer to the transformers standard. @Namangarg110 What I would suggest is referring to @EduardoPach's PR to help guide on the transformers standard and making sure to add @EduardoPach as a joint contributor on the model page. You can both work together here to iterate on this branch. @Namangarg110, if you don't think you'll be able to have the PR ready i.e. transformers-level and in it's final review stage, within the next two weeks then we should close this PR and use @EduardoPach's. 

@EduardoPach next time, it's better to check first on the currently open PR. If it's active and if you notice things that could be updated in the PR to align with transformers, a great way to help the community is comment directly on the open PR on changes that could be made.