




'''simple docstring'''


import argparse
import os

import torch

from transformers import (
    XLNetConfig,
    XLNetForQuestionAnswering,
    XLNetForSequenceClassification,
    XLNetLMHeadModel,
    load_tf_weights_in_xlnet,
)
from transformers.utils import CONFIG_NAME, WEIGHTS_NAME, logging


UpperCAmelCase_ 		=      {
    "cola": 2,
    "mnli": 3,
    "mrpc": 2,
    "sst-2": 2,
    "sts-b": 1,
    "qqp": 2,
    "qnli": 2,
    "rte": 2,
    "wnli": 2,
}


logging.set_verbosity_info()


def 						SCREAMING_SNAKE_CASE       (      a_	:							str				,					a_	:							Any				,					a_	:							Dict				,					a_	:							Optional[Any]=None			):
  # Initialise PyTorch model
  __a			=					XLNetConfig.from_json_file(a_			)

  __a			=					finetuning_task.lower() if finetuning_task is not None else ''
  if finetuning_task in GLUE_TASKS_NUM_LABELS:
    print(f"Building PyTorch XLNetForSequenceClassification model from configuration: {config}"			)
    __a			=					finetuning_task
    __a			=					GLUE_TASKS_NUM_LABELS[finetuning_task]
    __a			=					XLNetForSequenceClassification(a_			)
  elif "squad" in finetuning_task:
    __a			=					finetuning_task
    __a			=					XLNetForQuestionAnswering(a_			)
  else:
    __a			=					XLNetLMHeadModel(a_			)

  # Load weights from tf checkpoint
  load_tf_weights_in_xlnet(a_				,					a_				,					a_			)

  # Save pytorch-model
  __a			=					os.path.join(a_				,					a_			)
  __a			=					os.path.join(a_				,					a_			)
  print(f"Save PyTorch model to {os.path.abspath(a_			)}"			)
  torch.save(model.state_dict()				,					a_			)
  print(f"Save configuration file to {os.path.abspath(a_			)}"			)
  with open(a_				,					'w'				,					encoding='utf-8'			) as f:
    f.write(config.to_json_string()			)


if __name__ == "__main__":
  UpperCAmelCase_ 		=      argparse.ArgumentParser()
  # Required parameters
  parser.add_argument(
      "--tf_checkpoint_path", default=None, type=str, required=True, help="Path to the TensorFlow checkpoint path."
  )
  parser.add_argument(
      "--xlnet_config_file",
      default=None,
      type=str,
      required=True,
      help=(
          "The config json file corresponding to the pre-trained XLNet model. \n"
          "This specifies the model architecture."
      ),
  )
  parser.add_argument(
      "--pytorch_dump_folder_path",
      default=None,
      type=str,
      required=True,
      help="Path to the folder to store the PyTorch model or dataset/vocab.",
  )
  parser.add_argument(
      "--finetuning_task",
      default=None,
      type=str,
      help="Name of a task on which the XLNet TensorFlow model was fine-tuned",
  )
  UpperCAmelCase_ 		=      parser.parse_args()
  print(args)

  convert_xlnet_checkpoint_to_pytorch(
      args.tf_checkpoint_path, args.xlnet_config_file, args.pytorch_dump_folder_path, args.finetuning_task
  )









'''simple docstring'''


import os
from datetime import datetime as dt

from github import Github


UpperCAmelCase_ 		=      [
    "good first issue",
    "good second issue",
    "good difficult issue",
    "enhancement",
    "new pipeline/model",
    "new scheduler",
    "wip",
]


def 						SCREAMING_SNAKE_CASE       (      ):
  __a			=					Github(os.environ['GITHUB_TOKEN']			)
  __a			=					g.get_repo('huggingface/diffusers'			)
  __a			=					repo.get_issues(state='open'			)

  for issue in open_issues:
    __a			=					sorted(issue.get_comments()				,					key=lambda a_			: i.created_at				,					reverse=a_			)
    __a			=					comments[0] if len(a_			) > 0 else None
    if (
        last_comment is not None
        and last_comment.user.login == "github-actions[bot]"
        and (dt.utcnow() - issue.updated_at).days > 7
        and (dt.utcnow() - issue.created_at).days >= 30
        and not any(label.name.lower() in LABELS_TO_EXEMPT for label in issue.get_labels()			)
    ):
      # Closes the issue after 7 days of inactivity since the Stalebot notification.
      issue.edit(state='closed'			)
    elif (
        "stale" in issue.get_labels()
        and last_comment is not None
        and last_comment.user.login != "github-actions[bot]"
    ):
      # Opens the issue if someone other than Stalebot commented.
      issue.edit(state='open'			)
      issue.remove_from_labels('stale'			)
    elif (
        (dt.utcnow() - issue.updated_at).days > 23
        and (dt.utcnow() - issue.created_at).days >= 30
        and not any(label.name.lower() in LABELS_TO_EXEMPT for label in issue.get_labels()			)
    ):
      # Post a Stalebot notification after 23 days of inactivity.
      issue.create_comment(
          'This issue has been automatically marked as stale because it has not had '
          'recent activity. If you think this still needs to be addressed '
          'please comment on this thread.\n\nPlease note that issues that do not follow the '
          '[contributing guidelines](https://github.com/huggingface/diffusers/blob/main/CONTRIBUTING.md) '
          'are likely to be ignored.'			)
      issue.add_to_labels('stale'			)


if __name__ == "__main__":
  main()



