'''simple docstring'''




import argparse
import os
import platform

import numpy as np
import psutil
import torch

from accelerate import __version__ as version
from accelerate.commands.config import default_config_file, load_config_from_file

from ..utils import is_npu_available, is_xpu_available







def       A_ (			_lowerCamelCase      :				str=None     ):







      if subparsers is not None:
            _lowerCAmelCase		 = subparsers.add_parser('env'     )
      else:
            _lowerCAmelCase		 = argparse.ArgumentParser('Accelerate env command'     )

      parser.add_argument(
          '--config_file'	,	default=_lowerCamelCase	,	help='The config file to use for the default values in the launching script.'     )

      if subparsers is not None:
            parser.set_defaults(func=_lowerCamelCase     )
      return parser







def       A_ (			_lowerCamelCase      :				Dict     ):
      _lowerCAmelCase		 = torch.__version__
      _lowerCAmelCase		 = torch.cuda.is_available()
      _lowerCAmelCase		 = is_xpu_available()
      _lowerCAmelCase		 = is_npu_available()

      _lowerCAmelCase		 = 'Not found'
      # Get the default from the config file.
      if args.config_file is not None or os.path.isfile(_lowerCamelCase     ):
            _lowerCAmelCase		 = load_config_from_file(args.config_file     ).to_dict()

      _lowerCAmelCase		 = {
          '`Accelerate` version': version,
          'Platform': platform.platform(),
          'Python version': platform.python_version(),
          'Numpy version': np.__version__,
          'PyTorch version (GPU?)': F"{pt_version} ({pt_cuda_available})",
          'PyTorch XPU available': str(_lowerCamelCase     ),
          'PyTorch NPU available': str(_lowerCamelCase     ),
          'System RAM': F"{psutil.virtual_memory().total / 1_024 ** 3:.2f} GB",
      }
      if pt_cuda_available:
            _lowerCAmelCase		 = torch.cuda.get_device_name()

      print('\nCopy-and-paste the text below in your GitHub issue\n'     )
      print('\n'.join([F"- {prop}: {val}" for prop, val in info.items()]     )     )

      print('- `Accelerate` default config:' if args.config_file is None else '- `Accelerate` config passed:'     )
      _lowerCAmelCase		 = (
          '\n'.join([F"\t- {prop}: {val}" for prop, val in accelerate_config.items()]     )
          if isinstance(_lowerCamelCase	,	_lowerCamelCase     )
          else F"\t{accelerate_config}"
      )
      print(_lowerCamelCase     )

      _lowerCAmelCase		 = accelerate_config

      return info







def       A_ (			):
      _lowerCAmelCase		 = env_command_parser()
      _lowerCAmelCase		 = parser.parse_args()
      env_command(_lowerCamelCase     )
      return 0


if __name__ == "__main__":
 raise SystemExit(main())









'''simple docstring'''

def _SCREAMING_SNAKE_CASE (A			)			->			bool:






       """simple docstring"""







       if not isinstance(A    ,					A			):
              raise ValueError('''Input series is not valid, valid series - [2, 4, 6]'''			)
       if len(A			) == 0:
              raise ValueError('''Input list must be a non empty list'''			)
       if len(A			) == 1:
              return True
       lowercase__      =					series[1] - series[0]
       for index in range(len(A			) - 1			):
              if series[index + 1] - series[index] != common_diff:
                     return False
       return True

def _SCREAMING_SNAKE_CASE (A			)			->			float:






       """simple docstring"""







       if not isinstance(A    ,					A			):
              raise ValueError('''Input series is not valid, valid series - [2, 4, 6]'''			)
       if len(A			) == 0:
              raise ValueError('''Input list must be a non empty list'''			)
       lowercase__      =					0
       for val in series:
              answer += val
       return answer / len(A			)


if __name__ == "__main__":
 import doctest

 doctest.testmod()




