





from __future__ import annotations

from math import pi, pow







def       lowerCAmelCase__(	lowercase       :    int				) ->    float:







  if side_length < 0:
    raise ValueError("vol_cube() only accepts non-negative values"				)
  return pow(lowercase   ,     3				)







def       lowerCAmelCase__(	lowercase       :    Dict   ,     lowercase       :    int				) ->    float:







  if height < 0 or radius < 0:
    raise ValueError("vol_spherical_cap() only accepts non-negative values"				)
  # Volume is 1/3 pi * height squared * (3 * radius - height)
  return 1 / 3 * pi * pow(lowercase   ,     2				) * (3 * radius - height)







def       lowerCAmelCase__(	lowercase       :    str   ,     lowercase       :    int   ,     lowercase       :    Union[str, Any]				) ->    float:







  if radius_a < 0 or radius_a < 0 or centers_distance < 0:
    raise ValueError("vol_spheres_intersect() only accepts non-negative values"				)
  if centers_distance == 0:
    return vol_sphere(min(lowercase   ,     lowercase				)				)

  __snake_case   :				Dict        =       (
      (radius_a - radius_a + centers_distance)
      * (radius_a + radius_a - centers_distance)
      / (2 * centers_distance)
  )
  __snake_case   :				str        =       (
      (radius_a - radius_a + centers_distance)
      * (radius_a + radius_a - centers_distance)
      / (2 * centers_distance)
  )

  return vol_spherical_cap(lowercase   ,     lowercase				) + vol_spherical_cap(lowercase   ,     lowercase				)







def       lowerCAmelCase__(	lowercase       :    str   ,     lowercase       :    Union[str, Any]   ,     lowercase       :    str				) ->    float:







  if radius_a <= 0 or radius_a <= 0 or centers_distance < 0:
    raise ValueError(
        "vol_spheres_union() only accepts non-negative values, non-zero radius"				)

  if centers_distance == 0:
    return vol_sphere(max(lowercase   ,     lowercase				)				)

  return (
      vol_sphere(lowercase				)
      + vol_sphere(lowercase				)
      - vol_spheres_intersect(lowercase   ,     lowercase   ,     lowercase				)
  )







def       lowerCAmelCase__(	lowercase       :    List[Any]   ,     lowercase       :    Optional[Any]   ,     lowercase       :    Any				) ->    float:







  if width < 0 or height < 0 or length < 0:
    raise ValueError("vol_cuboid() only accepts non-negative values"				)
  return float(width * height * length				)







def       lowerCAmelCase__(	lowercase       :    List[str]   ,     lowercase       :    int				) ->    float:







  if height < 0 or area_of_base < 0:
    raise ValueError("vol_cone() only accepts non-negative values"				)
  return area_of_base * height / 3.0







def       lowerCAmelCase__(	lowercase       :    Optional[Any]   ,     lowercase       :    int				) ->    float:







  if height < 0 or radius < 0:
    raise ValueError("vol_right_circ_cone() only accepts non-negative values"				)
  return pi * pow(lowercase   ,     2				) * height / 3.0







def       lowerCAmelCase__(	lowercase       :    Any   ,     lowercase       :    Optional[Any]				) ->    float:







  if height < 0 or area_of_base < 0:
    raise ValueError("vol_prism() only accepts non-negative values"				)
  return float(area_of_base * height				)







def       lowerCAmelCase__(	lowercase       :    str   ,     lowercase       :    Optional[Any]				) ->    float:







  if height < 0 or area_of_base < 0:
    raise ValueError("vol_pyramid() only accepts non-negative values"				)
  return area_of_base * height / 3.0







def       lowerCAmelCase__(	lowercase       :    List[str]				) ->    float:







  if radius < 0:
    raise ValueError("vol_sphere() only accepts non-negative values"				)
  # Volume is 4/3 * pi * radius cubed
  return 4 / 3 * pi * pow(lowercase   ,     3				)







def       lowerCAmelCase__(	lowercase       :    List[str]				) ->    float:







  if radius < 0:
    raise ValueError("vol_hemisphere() only accepts non-negative values"				)
  # Volume is radius cubed * pi * 2/3
  return pow(lowercase   ,     3				) * pi * 2 / 3







def       lowerCAmelCase__(	lowercase       :    Any   ,     lowercase       :    Tuple				) ->    float:







  if height < 0 or radius < 0:
    raise ValueError("vol_circular_cylinder() only accepts non-negative values"				)
  # Volume is radius squared * height * pi
  return pow(lowercase   ,     2				) * height * pi







def       lowerCAmelCase__(	lowercase       :    Union[str, Any]   ,     lowercase       :    str   ,     lowercase       :    Tuple				) ->    float:







  if inner_radius < 0 or outer_radius < 0 or height < 0:
    raise ValueError(
        "vol_hollow_circular_cylinder() only accepts non-negative values"				)
  if outer_radius <= inner_radius:
    raise ValueError("outer_radius must be greater than inner_radius"				)
  return pi * (pow(lowercase   ,     2				) - pow(lowercase   ,     2				)) * height







def       lowerCAmelCase__(	lowercase       :    Union[str, Any]   ,     lowercase       :    Optional[Any]   ,     lowercase       :    Tuple				) ->    float:







  if radius_a < 0 or radius_a < 0 or height < 0:
    raise ValueError("vol_conical_frustum() only accepts non-negative values"				)
  return (
      1
      / 3
      * pi
      * height
      * (pow(lowercase   ,     2				) + pow(lowercase   ,     2				) + radius_a * radius_a)
  )







def       lowerCAmelCase__(	lowercase       :    List[str]   ,     lowercase       :    Optional[int]				) ->    float:







  if torus_radius < 0 or tube_radius < 0:
    raise ValueError("vol_torus() only accepts non-negative values"				)
  return 2 * pow(lowercase   ,     2				) * torus_radius * pow(lowercase   ,     2				)







def       lowerCAmelCase__(	) ->    Dict:
  print("Volumes:"				)
  print(f"""Cube: {vol_cube(2				) = }"""				)  # = 8
  print(f"""Cuboid: {vol_cuboid(2   ,     2   ,     2				) = }"""				)  # = 8
  print(f"""Cone: {vol_cone(2   ,     2				) = }"""				)  # ~= 1.33
  print(f"""Right Circular Cone: {vol_right_circ_cone(2   ,     2				) = }"""				)  # ~= 8.38
  print(f"""Prism: {vol_prism(2   ,     2				) = }"""				)  # = 4
  print(f"""Pyramid: {vol_pyramid(2   ,     2				) = }"""				)  # ~= 1.33
  print(f"""Sphere: {vol_sphere(2				) = }"""				)  # ~= 33.5
  print(f"""Hemisphere: {vol_hemisphere(2				) = }"""				)  # ~= 16.75
  print(f"""Circular Cylinder: {vol_circular_cylinder(2   ,     2				) = }"""				)  # ~= 25.1
  print(f"""Torus: {vol_torus(2   ,     2				) = }"""				)  # ~= 157.9
  print(f"""Conical Frustum: {vol_conical_frustum(2   ,     2   ,     4				) = }"""				)  # ~= 58.6
  print(f"""Spherical cap: {vol_spherical_cap(1   ,     2				) = }"""				)  # ~= 5.24
  print(f"""Spheres intersetion: {vol_spheres_intersect(2   ,     2   ,     1				) = }"""				)  # ~= 21.21
  print(f"""Spheres union: {vol_spheres_union(2   ,     2   ,     1				) = }"""				)  # ~= 45.81
  print(
      f"""Hollow Circular Cylinder: {vol_hollow_circular_cylinder(1   ,     2   ,     3				) = }"""				)  # ~= 28.3


if __name__ == "__main__":
      main()








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 				_lowerCamelCase (    a    ):



      """simple docstring"""






      @staticmethod
      def 						UpperCAmelCase		( UpperCAmelCase   )       ->   Any:






        '''simple docstring'''






        __snake_case   :				Dict        =       parser.add_parser("login"				,						help="Log in using the same credentials as on huggingface.co"   )
        login_parser.set_defaults(func=lambda UpperCAmelCase   : LoginCommand(UpperCAmelCase   )   )
        __snake_case   :				int        =       parser.add_parser("whoami"				,						help="Find out which huggingface.co account you are logged in as."   )
        whoami_parser.set_defaults(func=lambda UpperCAmelCase   : WhoamiCommand(UpperCAmelCase   )   )
        __snake_case   :				int        =       parser.add_parser("logout"				,						help="Log out"   )
        logout_parser.set_defaults(func=lambda UpperCAmelCase   : LogoutCommand(UpperCAmelCase   )   )

        # new system: git-based repo system
        __snake_case   :				Union[str, Any]        =       parser.add_parser(
            "repo"				,						help="Deprecated: use `huggingface-cli` instead. Commands to interact with your huggingface.co repos."				,						)
        __snake_case   :				List[str]        =       repo_parser.add_subparsers(
            help="Deprecated: use `huggingface-cli` instead. huggingface.co repos related commands"   )
        __snake_case   :				int        =       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=UpperCAmelCase				,						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=UpperCAmelCase				,						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 UpperCAmelCase   : RepoCreateCommand(UpperCAmelCase   )   )




class 				_lowerCamelCase :



      """simple docstring"""






      UpperCAmelCase_						:      Tuple       ="\u001b[1m"
      UpperCAmelCase_						:      int       ="\u001b[31m"
      UpperCAmelCase_						:      Optional[Any]       ="\u001b[90m"
      UpperCAmelCase_						:      Optional[Any]       ="\u001b[0m"







      @classmethod
      def 						UpperCAmelCase		( cls				,						UpperCAmelCase   )       ->   Union[str, Any]:






        '''simple docstring'''






        return F"""{cls._bold}{s}{cls._reset}"""







      @classmethod
      def 						UpperCAmelCase		( cls				,						UpperCAmelCase   )       ->   Optional[int]:






        '''simple docstring'''






        return F"""{cls._bold}{cls._red}{s}{cls._reset}"""







      @classmethod
      def 						UpperCAmelCase		( cls				,						UpperCAmelCase   )       ->   List[str]:






        '''simple docstring'''






        return F"""{cls._gray}{s}{cls._reset}"""







def       lowerCAmelCase__(	lowercase       :    List[List[Union[str, int]]]   ,     lowercase       :    List[str]				) ->    str:
  __snake_case   :				Dict        =       [max(len(str(lowercase				)				) for x in col				) for col in zip(*lowercase   ,     lowercase				)]
  __snake_case   :				str        =       ("{{:{}}} " * len(lowercase				)).format(*lowercase				)
  __snake_case   :				Tuple        =       []
  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 				_lowerCamelCase :



      """simple docstring"""






      def __init__( self				,						UpperCAmelCase   )       ->   Dict:






        '''simple docstring'''






        __snake_case   :				List[str]        =       args




class 				_lowerCamelCase (    a    ):



      """simple docstring"""






      def 						UpperCAmelCase		( self   )       ->   Union[str, Any]:






        '''simple docstring'''






        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 				_lowerCamelCase (    a    ):



      """simple docstring"""






      def 						UpperCAmelCase		( self   )       ->   str:






        '''simple docstring'''






        print(
            ANSI.red(
                "WARNING! `transformers-cli whoami` is deprecated and will be removed in v5. Please use "
                "`huggingface-cli whoami` instead."   )   )
        __snake_case   :				Optional[Any]        =       HfFolder.get_token()
        if token is None:
          print("Not logged in"   )
          exit()
        try:
          __snake_case    ,   __snake_case   :				Tuple        =       whoami(UpperCAmelCase   )
          print(UpperCAmelCase   )
          if orgs:
            print(ANSI.bold("orgs: "   )				,						",".join(UpperCAmelCase   )   )
        except HTTPError as e:
          print(UpperCAmelCase   )
          print(ANSI.red(e.response.text   )   )
          exit(1   )




class 				_lowerCamelCase (    a    ):



      """simple docstring"""






      def 						UpperCAmelCase		( self   )       ->   List[str]:






        '''simple docstring'''






        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 				_lowerCamelCase (    a    ):



      """simple docstring"""






      def 						UpperCAmelCase		( self   )       ->   Tuple:






        '''simple docstring'''






        print(
            ANSI.red(
                "WARNING! Managing repositories through transformers-cli is deprecated. "
                "Please use `huggingface-cli` instead."   )   )
        __snake_case   :				Dict        =       HfFolder.get_token()
        if token is None:
          print("Not logged in"   )
          exit(1   )
        try:
          __snake_case   :				Optional[int]        =       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:
          __snake_case   :				Union[str, Any]        =       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(""   )

        __snake_case    ,   __snake_case   :				Any        =       whoami(UpperCAmelCase   )
        __snake_case   :				List[str]        =       self.args.organization if self.args.organization is not None else user
        __snake_case   :				Any        =       F"""{namespace}/{self.args.name}"""
        print(F"""You are about to create {ANSI.bold(UpperCAmelCase   )}"""   )

        if not self.args.yes:
          __snake_case   :				Optional[int]        =       input("Proceed? [Y/n] "   ).lower()
          if not (choice == "" or choice == "y" or choice == "yes"):
            print("Abort"   )
            exit()
        try:
          __snake_case   :				List[str]        =       create_repo(UpperCAmelCase				,						name=self.args.name				,						organization=self.args.organization   )
        except HTTPError as e:
          print(UpperCAmelCase   )
          print(ANSI.red(e.response.text   )   )
          exit(1   )
        print("\nYour repo now lives at:"   )
        print(F"""  {ANSI.bold(UpperCAmelCase   )}"""   )
        print("\nYou can clone it locally with the command below, and commit/push as usual."   )
        print(F"""\n  git clone {url}"""   )
        print(""   )

