[WIP] Hivemind Integration
Author: chavinlo
Pull request: yes

# What does this PR do?

This PR (will) add integration for hivemind (https://github.com/learning-at-home/hivemind), a PyTorch library for decentralized deep learning across the Internet.

## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [ ] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#start-contributing-pull-requests),
      Pull Request section?
- [ ] 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.
- [ ] 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.

<!-- 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 and @younesbelkada
- vision models: @amyeroberts
- speech models: @sanchit-gandhi
- graph models: @clefourrier

--!>

Library:

<!-- 
- flax: @sanchit-gandhi
- generate: @gante
- pipelines: @Narsil
- tensorflow: @gante and @Rocketknight1
- tokenizers: @ArthurZucker --!>

- trainer: @sgugger

<!-- 
Integrations:

- deepspeed: HF Trainer/Accelerate: @pacman100
- ray/raytune: @richardliaw, @amogkam

Documentation: @sgugger, @stevhliu and @MKhalusova

HF projects:

- accelerate: [different repo](https://github.com/huggingface/accelerate)
- datasets: [different repo](https://github.com/huggingface/datasets)
- diffusers: [different repo](https://github.com/huggingface/diffusers)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Maintained examples (not research project or legacy):

- Flax: @sanchit-gandhi
- PyTorch: @sgugger
- TensorFlow: @Rocketknight1

 -->


Comments:
The idea is to allow for an "infinite run" with hivemind where users can join using the hivemind DHT.
The DHT will have to be initialized before initiating the trainingarguments so that the user can mess with it more freely, then the optimizer kwargs will just be passed on internally.

Most of the changes are related to `max_steps`. Although hivemind should be able to work with it, I think it would be better to not use it to let it scale freely. (in other words, the user will not be able to predict the ammount of peers that will join to scale the max_steps well enough)

Right now I am having some issues with `steps_trained_in_current_epoch`, the tqdm progress bar, and wandb being enabled out of nowhere. However, it seems it can run some steps, it just doesn't reports it (wandb or progress bar)

Some feedback would be nice.

> Thanks for your PR! This rewrites a lot of the `Trainer` internals, so maybe it should be better to define a `Trainer` subclass hosted on the `hivemind` side?

I was thinking of that too but then what would happen with the sub trainers? (Seq2Seq for example) I have no problem with that though.

> Right now I am having some issues with steps_trained_in_current_epoch, the tqdm progress bar, and wandb being enabled out of nowhere. However, it seems it can run some steps, it just doesn't reports it (wandb or progress bar)

@sgugger 
Edit: solved by `self.total_batched_samples = self.total_batched_samples + 1`

Will reopen this once I believe it's good enough and has a clean integration.
For now I will just use it internally