
"""simple docstring"""

import inspect
import os
import unittest

import torch

import accelerate
from accelerate import debug_launcher
from accelerate.test_utils import (
    execute_subprocess_async,
    require_cpu,
    require_huggingface_suite,
    require_multi_gpu,
    require_single_gpu,
)
from accelerate.utils import patch_environment
@require_huggingface_suite
class      _UpperCAmelCase							(		unittest.TestCase							):




      def     a_      (							self							)						->					str:
          UpperCAmelCase									=					inspect.getfile(accelerate.test_utils							)
          UpperCAmelCase									=					os.path.sep.join(
              mod_file.split(os.path.sep							)[:-1] + ['scripts', 'external_deps', 'test_metrics.py']							)

          from accelerate.test_utils.scripts.external_deps import test_metrics  # noqa: F401

          UpperCAmelCase									=					test_metrics




      @require_cpu
      def     a_      (							self							)						->					Tuple:
          debug_launcher(self.test_metrics.main   ,       num_processes=1							)




      @require_cpu
      def     a_      (							self							)						->					Union[str, Any]:
          debug_launcher(self.test_metrics.main							)




      @require_single_gpu
      def     a_      (							self							)						->					int:
          self.test_metrics.main()




      @require_multi_gpu
      def     a_      (							self							)						->					int:
          print(F"Found {torch.cuda.device_count()} devices."							)
          UpperCAmelCase									=					["torchrun", F"--nproc_per_node={torch.cuda.device_count()}", self.test_file_path]
          with patch_environment(omp_num_threads=1							):
              execute_subprocess_async(lowerCAmelCase__   ,       env=os.environ.copy()							)





"""simple docstring"""

def     lowercase__						(					lowerCAmelCase				:					int ,				lowerCAmelCase				:					int ) ->      int:






    """simple docstring"""




    return number | (1 << position)




def     lowercase__						(					lowerCAmelCase				:					int ,				lowerCAmelCase				:					int ) ->      int:






    """simple docstring"""




    return number & ~(1 << position)




def     lowercase__						(					lowerCAmelCase				:					int ,				lowerCAmelCase				:					int ) ->      int:






    """simple docstring"""




    return number ^ (1 << position)




def     lowercase__						(					lowerCAmelCase				:					int ,				lowerCAmelCase				:					int ) ->      bool:






    """simple docstring"""




    return ((number >> position) & 1) == 1




def     lowercase__						(					lowerCAmelCase				:					int ,				lowerCAmelCase				:					int ) ->      int:






    """simple docstring"""




    return int((number & (1 << position)) != 0 )


if __name__ == "__main__":
   import doctest

   doctest.testmod()



