
"""simple docstring"""

from math import ceil






def 							A						(    snake_case				:str    , snake_case				:Tuple		)				->     str:
 __UpperCamelCase      =	list(range(0    , snake_case		)		)

 __UpperCamelCase      =	[item for sublist in list(device_map.values()		) for item in sublist]

 # Duplicate check
 __UpperCamelCase      =	[]
 for i in device_map_blocks:
  if device_map_blocks.count(snake_case		) > 1 and i not in duplicate_blocks:
   duplicate_blocks.append(snake_case		)
    # Missing blocks
 __UpperCamelCase      =	[i for i in blocks if i not in device_map_blocks]
 __UpperCamelCase      =	[i for i in device_map_blocks if i not in blocks]

 if len(snake_case		) != 0:
  raise ValueError(
      'Duplicate attention blocks specified in device_map. Attention blocks must be specified to one device.'
      ' These attention blocks were specified more than once: ' + str(snake_case		)		)
 if len(snake_case		) != 0:
  raise ValueError(
      'There are attention blocks for this model that are not specified in the device_map. Add these attention '
      'blocks to a device on the device_map: ' + str(snake_case		)		)
 if len(snake_case		) != 0:
  raise ValueError(
      'The device_map contains more attention blocks than this model has. Remove these from the device_map:'
      + str(snake_case		)		)






def 							A						(    snake_case				:int    , snake_case				:str		)				->     Any:
 __UpperCamelCase      =	list(range(snake_case		)		)
 __UpperCamelCase      =	int(ceil(n_layers / len(snake_case		)		)		)
 __UpperCamelCase      =	[layers[i : i + n_blocks] for i in range(0    , snake_case    , snake_case		)]

 return dict(zip(snake_case    , snake_case		)		)





"""simple docstring"""

from argparse import ArgumentParser

from .add_new_model import AddNewModelCommand
from .add_new_model_like import AddNewModelLikeCommand
from .convert import ConvertCommand
from .download import DownloadCommand
from .env import EnvironmentCommand
from .lfs import LfsCommands
from .pt_to_tf import PTtoTFCommand
from .run import RunCommand
from .serving import ServeCommand
from .user import UserCommands






def 							A						(    )				->     Union[str, Any]:
 __UpperCamelCase      =	ArgumentParser('Transformers CLI tool'    , usage='transformers-cli <command> [<args>]'		)
 __UpperCamelCase      =	parser.add_subparsers(help='transformers-cli command helpers'		)

 # Register commands
 ConvertCommand.register_subcommand(snake_case		)
 DownloadCommand.register_subcommand(snake_case		)
 EnvironmentCommand.register_subcommand(snake_case		)
 RunCommand.register_subcommand(snake_case		)
 ServeCommand.register_subcommand(snake_case		)
 UserCommands.register_subcommand(snake_case		)
 AddNewModelCommand.register_subcommand(snake_case		)
 AddNewModelLikeCommand.register_subcommand(snake_case		)
 LfsCommands.register_subcommand(snake_case		)
 PTtoTFCommand.register_subcommand(snake_case		)

 # Let's go
 __UpperCamelCase      =	parser.parse_args()

 if not hasattr(snake_case    , 'func'		):
  parser.print_help()
  exit(1		)

 # Run
 __UpperCamelCase      =	args.func(snake_case		)
 service.run()


if __name__ == "__main__":
      main()



