code: 
  
  """simple docstring"""
  
  
  
  
  import subprocess
  from argparse import ArgumentParser
  from typing import List, Union
  
  from huggingface_hub.hf_api import HfFolder, create_repo, whoami
  from requests.exceptions import HTTPError
  
  from . import BaseTransformersCLICommand
  
  
  
  
  
  class     __UpperCamelCase				(     _a		):
  
  
  		@staticmethod
  		def       SCREAMING_SNAKE_CASE__     (__SCREAMING_SNAKE_CASE				:	Optional[int]):
  							A    =      parser.add_parser("login"  ,  help="Log in using the same credentials as on huggingface.co")
  							login_parser.set_defaults(func=lambda __SCREAMING_SNAKE_CASE: LoginCommand(lowerCamelCase__))
  							A    =      parser.add_parser("whoami"  ,  help="Find out which huggingface.co account you are logged in as.")
  							whoami_parser.set_defaults(func=lambda __SCREAMING_SNAKE_CASE: WhoamiCommand(lowerCamelCase__))
  							A    =      parser.add_parser("logout"  ,  help="Log out")
  							logout_parser.set_defaults(func=lambda __SCREAMING_SNAKE_CASE: LogoutCommand(lowerCamelCase__))
  
  							# new system: git-based repo system
  							A    =      parser.add_parser(
  							    "repo"  ,  help="Deprecated: use `huggingface-cli` instead. Commands to interact with your huggingface.co repos."  ,  )
  							A    =      repo_parser.add_subparsers(
  							    help="Deprecated: use `huggingface-cli` instead. huggingface.co repos related commands")
  							A    =      repo_subparsers.add_parser(
  							    "create"  ,  help="Deprecated: use `huggingface-cli` instead. Create a new repo on huggingface.co")
  							repo_create_parser.add_argument(
  							    "name"  ,  type=lowerCamelCase__  ,  help="Name for your model's repo. Will be namespaced under your username to build the model id."  ,  )
  							repo_create_parser.add_argument("--organization"  ,  type=lowerCamelCase__  ,  help="Optional: organization namespace.")
  							repo_create_parser.add_argument("-y"  ,  "--yes"  ,  action="store_true"  ,  help="Optional: answer Yes to the prompt")
  							repo_create_parser.set_defaults(func=lambda __SCREAMING_SNAKE_CASE: RepoCreateCommand(lowerCamelCase__))
  
  
  
  
  
  class     __UpperCamelCase				:
  		SCREAMING_SNAKE_CASE              =					"\u001b[1m"
  		SCREAMING_SNAKE_CASE              =					"\u001b[31m"
  		SCREAMING_SNAKE_CASE              =					"\u001b[90m"
  		SCREAMING_SNAKE_CASE              =					"\u001b[0m"
  
  
  		@classmethod
  		def       SCREAMING_SNAKE_CASE__     (cls				:	Dict  ,  __SCREAMING_SNAKE_CASE				:	List[Any]):
  							return F"""{cls._bold}{s}{cls._reset}"""
  
  
  		@classmethod
  		def       SCREAMING_SNAKE_CASE__     (cls				:	Tuple  ,  __SCREAMING_SNAKE_CASE				:	List[Any]):
  							return F"""{cls._bold}{cls._red}{s}{cls._reset}"""
  
  
  		@classmethod
  		def       SCREAMING_SNAKE_CASE__     (cls				:	List[Any]  ,  __SCREAMING_SNAKE_CASE				:	Optional[int]):
  							return F"""{cls._gray}{s}{cls._reset}"""
  
  def      __SCREAMING_SNAKE_CASE		(		lowercase__    ,							lowercase__   ):
  					"""simple docstring"""
  					A    =      [max(len(str(lowercase__   )   ) for x in col   ) for col in zip(*lowercase__    ,							lowercase__   )]
  					A    =      ("{{:{}}} " * len(lowercase__   )).format(*lowercase__   )
  					A    =      []
  					lines.append(row_format.format(*lowercase__   )   )
  					lines.append(row_format.format(*["-" * w for w in col_widths]   )   )
  					for row in rows:
  										lines.append(row_format.format(*lowercase__   )   )
  					return "\n".join(lowercase__   )
  
  
  
  
  
  class     __UpperCamelCase				:
  
  
  		def __init__(self				:	Union[str, Any]  ,  __SCREAMING_SNAKE_CASE				:	Tuple):
  							A    =      args
  
  
  
  
  
  class     __UpperCamelCase				(     _a		):
  
  
  		def       SCREAMING_SNAKE_CASE__     (self				:	Any):
  							print(
  							    ANSI.red(
  							        "ERROR! `huggingface-cli login` uses an outdated login mechanism "
  							        "that is not compatible with the Hugging Face Hub backend anymore. "
  							        "Please use `huggingface-cli login instead."))
  
  
  
  
  
  class     __UpperCamelCase				(     _a		):
  
  
  		def       SCREAMING_SNAKE_CASE__     (self				:	Optional[Any]):
  							print(
  							    ANSI.red(
  							        "WARNING! `transformers-cli whoami` is deprecated and will be removed in v5. Please use "
  							        "`huggingface-cli whoami` instead."))
  							A    =      HfFolder.get_token()
  							if token is None:
  												print("Not logged in")
  												exit()
  							try:
  												A    =      whoami(lowerCamelCase__)
  												print(lowerCamelCase__)
  												if orgs:
  																	print(ANSI.bold("orgs: ")  ,  ",".join(lowerCamelCase__))
  							except HTTPError as e:
  												print(lowerCamelCase__)
  												print(ANSI.red(e.response.text))
  												exit(1)
  
  
  
  
  
  class     __UpperCamelCase				(     _a		):
  
  
  		def       SCREAMING_SNAKE_CASE__     (self				:	Optional[int]):
  							print(
  							    ANSI.red(
  							        "ERROR! `transformers-cli logout` uses an outdated logout mechanism "
  							        "that is not compatible with the Hugging Face Hub backend anymore. "
  							        "Please use `huggingface-cli logout instead."))
  
  
  
  
  
  class     __UpperCamelCase				(     _a		):
  
  
  		def       SCREAMING_SNAKE_CASE__     (self				:	List[Any]):
  							print(
  							    ANSI.red(
  							        "WARNING! Managing repositories through transformers-cli is deprecated. "
  							        "Please use `huggingface-cli` instead."))
  							A    =      HfFolder.get_token()
  							if token is None:
  												print("Not logged in")
  												exit(1)
  							try:
  												A    =      subprocess.check_output(["git", "--version"]).decode("utf-8")
  												print(ANSI.gray(stdout.strip()))
  							except FileNotFoundError:
  												print("Looks like you do not have git installed, please install.")
  
  							try:
  												A    =      subprocess.check_output(["git-lfs", "--version"]).decode("utf-8")
  												print(ANSI.gray(stdout.strip()))
  							except FileNotFoundError:
  												print(
  												    ANSI.red(
  												        "Looks like you do not have git-lfs installed, please install."
  												        " You can install from https://git-lfs.github.com/."
  												        " Then run `git lfs install` (you only have to do this once)."))
  							print("")
  
  							A    =      whoami(lowerCamelCase__)
  							A    =      self.args.organization if self.args.organization is not None else user
  							A    =      F"""{namespace}/{self.args.name}"""
  							print(F"""You are about to create {ANSI.bold(lowerCamelCase__)}""")
  
  							if not self.args.yes:
  												A    =      input("Proceed? [Y/n] ").lower()
  												if not (choice == "" or choice == "y" or choice == "yes"):
  																	print("Abort")
  																	exit()
  							try:
  												A    =      create_repo(lowerCamelCase__  ,  name=self.args.name  ,  organization=self.args.organization)
  							except HTTPError as e:
  												print(lowerCamelCase__)
  												print(ANSI.red(e.response.text))
  												exit(1)
  							print("\nYour repo now lives at:")
  							print(F"""  {ANSI.bold(lowerCamelCase__)}""")
  							print("\nYou can clone it locally with the command below, and commit/push as usual.")
  							print(F"""\n  git clone {url}""")
  							print("")
  
  
  
  
  
  
style_context: 
  
  """simple docstring"""
  
  
  
  
  import unittest
  
  from transformers import (
      MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING,
      TF_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING,
      PreTrainedTokenizer,
      is_vision_available,
  )
  from transformers.pipelines import ImageClassificationPipeline, pipeline
  from transformers.testing_utils import (
      is_pipeline_test,
      nested_simplify,
      require_tf,
      require_torch,
      require_torch_or_tf,
      require_vision,
      slow,
  )
  
  from .test_pipelines_common import ANY
  
  
  if is_vision_available():
  	from PIL import Image
  else:
  
  
  
  
  
  	class     __UpperCamelCase				:
  
  
  			@staticmethod
  			def       SCREAMING_SNAKE_CASE__     (*__SCREAMING_SNAKE_CASE				:	Optional[Any]  ,  **__SCREAMING_SNAKE_CASE				:	Any):
  								pass
  
  
  
  
  
  @is_pipeline_test
  @require_torch_or_tf
  @require_vision
  class     __UpperCamelCase				(     unittest.TestCase		):
  		SCREAMING_SNAKE_CASE              =					MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING
  		SCREAMING_SNAKE_CASE              =					TF_MODEL_FOR_IMAGE_CLASSIFICATION_MAPPING
  
  
  		def       SCREAMING_SNAKE_CASE__     (self				:	Any  ,  __SCREAMING_SNAKE_CASE				:	List[str]  ,  __SCREAMING_SNAKE_CASE				:	Union[str, Any]  ,  __SCREAMING_SNAKE_CASE				:	Tuple):
  							A    =      ImageClassificationPipeline(model=__SCREAMING_SNAKE_CASE  ,  image_processor=__SCREAMING_SNAKE_CASE  ,  top_k=2)
  							A    =      [
  							    Image.open("./tests/fixtures/tests_samples/COCO/000000039769.png"),
  							    "http://images.cocodataset.org/val2017/000000039769.jpg",
  							]
  							return image_classifier, examples
  
  
  		def       SCREAMING_SNAKE_CASE__     (self				:	Any  ,  __SCREAMING_SNAKE_CASE				:	Optional[int]  ,  __SCREAMING_SNAKE_CASE				:	Dict):
  							A    =      image_classifier("./tests/fixtures/tests_samples/COCO/000000039769.png")
  
  							self.assertEqual(
  							    __SCREAMING_SNAKE_CASE  ,  [
  							        {"score": ANY(__SCREAMING_SNAKE_CASE), "label": ANY(__SCREAMING_SNAKE_CASE)},
  							        {"score": ANY(__SCREAMING_SNAKE_CASE), "label": ANY(__SCREAMING_SNAKE_CASE)},
  							    ]  ,  )
  
  							import datasets
  
  							A    =      datasets.load_dataset("hf-internal-testing/fixtures_image_utils"  ,  "image"  ,  split="test")
  
  							# Accepts URL + PIL.Image + lists
  							A    =      image_classifier(
  							    [
  							        Image.open("./tests/fixtures/tests_samples/COCO/000000039769.png"),
  							        "http://images.cocodataset.org/val2017/000000039769.jpg",
  							        # RGBA
  							        dataset[0]["file"],
  							        # LA
  							        dataset[1]["file"],
  							        # L
  							        dataset[2]["file"],
  							    ])
  							self.assertEqual(
  							    __SCREAMING_SNAKE_CASE  ,  [
  							        [
  							            {"score": ANY(__SCREAMING_SNAKE_CASE), "label": ANY(__SCREAMING_SNAKE_CASE)},
  							            {"score": ANY(__SCREAMING_SNAKE_CASE), "label": ANY(__SCREAMING_SNAKE_CASE)},
  							        ],
  							        [
  							            {"score": ANY(__SCREAMING_SNAKE_CASE), "label": ANY(__SCREAMING_SNAKE_CASE)},
  							            {"score": ANY(__SCREAMING_SNAKE_CASE), "label": ANY(__SCREAMING_SNAKE_CASE)},
  							        ],
  							        [
  							            {"score": ANY(__SCREAMING_SNAKE_CASE), "label": ANY(__SCREAMING_SNAKE_CASE)},
  							            {"score": ANY(__SCREAMING_SNAKE_CASE), "label": ANY(__SCREAMING_SNAKE_CASE)},
  							        ],
  							        [
  							            {"score": ANY(__SCREAMING_SNAKE_CASE), "label": ANY(__SCREAMING_SNAKE_CASE)},
  							            {"score": ANY(__SCREAMING_SNAKE_CASE), "label": ANY(__SCREAMING_SNAKE_CASE)},
  							        ],
  							        [
  							            {"score": ANY(__SCREAMING_SNAKE_CASE), "label": ANY(__SCREAMING_SNAKE_CASE)},
  							            {"score": ANY(__SCREAMING_SNAKE_CASE), "label": ANY(__SCREAMING_SNAKE_CASE)},
  							        ],
  							    ]  ,  )
  
  
  		@require_torch
  		def       SCREAMING_SNAKE_CASE__     (self				:	str):
  							A    =      "hf-internal-testing/tiny-random-vit"
  							A    =      pipeline("image-classification"  ,  model=__SCREAMING_SNAKE_CASE)
  
  							A    =      image_classifier("http://images.cocodataset.org/val2017/000000039769.jpg")
  							self.assertEqual(
  							    nested_simplify(__SCREAMING_SNAKE_CASE  ,  decimals=4)  ,  [{"label": "LABEL_1", "score": 0.5_7_4}, {"label": "LABEL_0", "score": 0.4_2_6}]  ,  )
  
  							A    =      image_classifier(
  							    [
  							        "http://images.cocodataset.org/val2017/000000039769.jpg",
  							        "http://images.cocodataset.org/val2017/000000039769.jpg",
  							    ]  ,  top_k=2  ,  )
  							self.assertEqual(
  							    nested_simplify(__SCREAMING_SNAKE_CASE  ,  decimals=4)  ,  [
  							        [{"label": "LABEL_1", "score": 0.5_7_4}, {"label": "LABEL_0", "score": 0.4_2_6}],
  							        [{"label": "LABEL_1", "score": 0.5_7_4}, {"label": "LABEL_0", "score": 0.4_2_6}],
  							    ]  ,  )
  
  
  		@require_tf
  		def       SCREAMING_SNAKE_CASE__     (self				:	List[str]):
  							A    =      "hf-internal-testing/tiny-random-vit"
  							A    =      pipeline("image-classification"  ,  model=__SCREAMING_SNAKE_CASE  ,  framework="tf")
  
  							A    =      image_classifier("http://images.cocodataset.org/val2017/000000039769.jpg")
  							self.assertEqual(
  							    nested_simplify(__SCREAMING_SNAKE_CASE  ,  decimals=4)  ,  [{"label": "LABEL_1", "score": 0.5_7_4}, {"label": "LABEL_0", "score": 0.4_2_6}]  ,  )
  
  							A    =      image_classifier(
  							    [
  							        "http://images.cocodataset.org/val2017/000000039769.jpg",
  							        "http://images.cocodataset.org/val2017/000000039769.jpg",
  							    ]  ,  top_k=2  ,  )
  							self.assertEqual(
  							    nested_simplify(__SCREAMING_SNAKE_CASE  ,  decimals=4)  ,  [
  							        [{"label": "LABEL_1", "score": 0.5_7_4}, {"label": "LABEL_0", "score": 0.4_2_6}],
  							        [{"label": "LABEL_1", "score": 0.5_7_4}, {"label": "LABEL_0", "score": 0.4_2_6}],
  							    ]  ,  )
  
  
  		def       SCREAMING_SNAKE_CASE__     (self				:	Union[str, Any]):
  							A    =      PreTrainedTokenizer()
  
  							# Assert that the pipeline can be initialized with a feature extractor that is not in any mapping
  							A    =      pipeline(
  							    "image-classification"  ,  model="hf-internal-testing/tiny-random-vit"  ,  tokenizer=__SCREAMING_SNAKE_CASE)
  
  							self.assertIs(image_classifier.tokenizer  ,  __SCREAMING_SNAKE_CASE)
  
  
  		@slow
  		@require_torch
  		def       SCREAMING_SNAKE_CASE__     (self				:	List[Any]):
  							# Perceiver is not tested by `run_pipeline_test` properly.
  							# That is because the type of feature_extractor and model preprocessor need to be kept
  							# in sync, which is not the case in the current design
  							A    =      pipeline("image-classification"  ,  model="deepmind/vision-perceiver-conv")
  							A    =      image_classifier("http://images.cocodataset.org/val2017/000000039769.jpg")
  							self.assertEqual(
  							    nested_simplify(__SCREAMING_SNAKE_CASE  ,  decimals=4)  ,  [
  							        {"score": 0.4_3_8_5, "label": "tabby, tabby cat"},
  							        {"score": 0.3_2_1, "label": "tiger cat"},
  							        {"score": 0.0_5_0_2, "label": "Egyptian cat"},
  							        {"score": 0.0_1_3_7, "label": "crib, cot"},
  							        {"score": 0.0_0_7, "label": "radiator"},
  							    ]  ,  )
  
  							A    =      pipeline("image-classification"  ,  model="deepmind/vision-perceiver-fourier")
  							A    =      image_classifier("http://images.cocodataset.org/val2017/000000039769.jpg")
  							self.assertEqual(
  							    nested_simplify(__SCREAMING_SNAKE_CASE  ,  decimals=4)  ,  [
  							        {"score": 0.5_6_5_8, "label": "tabby, tabby cat"},
  							        {"score": 0.1_3_0_9, "label": "tiger cat"},
  							        {"score": 0.0_7_2_2, "label": "Egyptian cat"},
  							        {"score": 0.0_7_0_7, "label": "remote control, remote"},
  							        {"score": 0.0_0_8_2, "label": "computer keyboard, keypad"},
  							    ]  ,  )
  
  							A    =      pipeline("image-classification"  ,  model="deepmind/vision-perceiver-learned")
  							A    =      image_classifier("http://images.cocodataset.org/val2017/000000039769.jpg")
  							self.assertEqual(
  							    nested_simplify(__SCREAMING_SNAKE_CASE  ,  decimals=4)  ,  [
  							        {"score": 0.3_0_2_2, "label": "tabby, tabby cat"},
  							        {"score": 0.2_3_6_2, "label": "Egyptian cat"},
  							        {"score": 0.1_8_5_6, "label": "tiger cat"},
  							        {"score": 0.0_3_2_4, "label": "remote control, remote"},
  							        {"score": 0.0_0_9_6, "label": "quilt, comforter, comfort, puff"},
  							    ]  ,  )
  
  
  
  
  
  