# What does this PR do?
Fixes #22312.
After internal discussions, it appears that adding the possibility to pad with `-1`  to `tokenizers` is not really feasible ( nor is it desirable). 
However, what we can do is by default resize the embedding layer to the nearest size that is optimal for the dtype of the model [following this](https://docs.nvidia.com/deeplearning/performance/dl-performance-matrix-multiplication/index.html#requirements-tc).

Motivations:
- the `_get_resized_embeddings` is not exposed, and thus making this automatic can be a big silent win. 
- if properly documented, should not really have issues. 

Cons:
- it is not backward compatible, so some kind of `config.optimise_resize` might be needed? 
- it is hidden and people might not really get why tokenizer.vocab_size will be different than the model's embedding dimension. 
[`resize_embedding`] Introduce `pad_to_multiple_of` and guidance. # What does this PR do?
Fixes #22312.
After internal discussions, it appears that adding the possibility to pad with `-1`  to `tokenizers` is not really feasible ( nor is it desirable). 
However, what we can do is by default resize the embedding layer to the nearest size that is optimal for the dtype of the model [following this](https://docs.nvidia.com/deeplearning/performance/dl-performance-matrix-multiplication/index.html#requirements-tc).

Motivations:
- the `_get_resized_embeddings` is not exposed, and thus making this automatic can be a big silent win. 
- if properly documented, should not really have issues. 

Cons:
- it is not backward compatible, so some kind of `config.optimise_resize` might be needed? 
- it is hidden and people might not really get why tokenizer.vocab_size will be different than the model's embedding dimension. 
import argparse
import json
import subprocess


def get_runner_status(target_runners, token):
    offline_runners = []

    cmd = (
        f'curl -H "Accept: application/vnd.github+json" -H "Authorization: Bearer {token}"'
        " https://api.github.com/repos/huggingface/transformers/actions/runners"
    )
    output = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE)
    o = output.stdout.decode("utf-8")
    status = json.loads(o)

    runners = status["runners"]
    for runner in runners:
        if runner["name"] in target_runners:
            if runner["status"] == "offline":
                offline_runners.append(runner)

    # save the result so we can report them on Slack
    with open("offline_runners.txt", "w") as fp:
        fp.write(json.dumps(offline_runners))

    if len(offline_runners) > 0:
        failed = "\n".join([x["name"] for x in offline_runners])
        raise ValueError(f"The following runners are offline:\n{failed}")


if __name__ == "__main__":

    def list_str(values):
        return values.split(",")

    parser = argparse.ArgumentParser()
    # Required parameters
    parser.add_argument(
        "--target_runners",
        default=None,
        type=list_str,
        required=True,
        help="Comma-separated list of runners to check status.",
    )

    parser.add_argument(
        "--token", default=None, type=str, required=True, help="A token that has actions:read permission."
    )
    args = parser.parse_args()

    get_runner_status(args.target_runners, args.token)

import argparse
import json
import subprocess


def get_runner_status(target_runners, token):
    offline_runners = []

    cmd = (
        f'curl -H "Accept: application/vnd.github+json" -H "Authorization: Bearer {token}"'
        " https://api.github.com/repos/huggingface/transformers/actions/runners"
    )
    output = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE)
    o = output.stdout.decode("utf-8")
    status = json.loads(o)

    runners = status["runners"]
    for runner in runners:
        if runner["name"] in target_runners:
            if runner["status"] == "offline":
                offline_runners.append(runner)

    # save the result so we can report them on Slack
    with open("offline_runners.txt", "w") as fp:
        fp.write(json.dumps(offline_runners))

    if len(offline_runners) > 0:
        failed = "\n".join([x["name"] for x in offline_runners])
        raise ValueError(f"The following runners are offline:\n{failed}")


if __name__ == "__main__":

    def list_str(values):
        return values.split(",")

    parser = argparse.ArgumentParser()
    # Required parameters
    parser.add_argument(
        "--target_runners",
        default=None,
        type=list_str,
        required=True,
        help="Comma-separated list of runners to check status.",
    )

    parser.add_argument(
        "--token", default=None, type=str, required=True, help="A token that has actions:read permission."
    )
    args = parser.parse_args()

    get_runner_status(args.target_runners, args.token)
