

"""simple docstring"""






import argparse
import datetime

def 		lowerCamelCase__		(					_lowerCamelCase   ):

    '''simple docstring'''



    _lowerCAmelCase       :   int  =    {
        '0': 'Sunday',
        '1': 'Monday',
        '2': 'Tuesday',
        '3': 'Wednesday',
        '4': 'Thursday',
        '5': 'Friday',
        '6': 'Saturday',
    }

    _lowerCAmelCase       :   Dict  =    {0: 1, 1: 2, 2: 3, 3: 4, 4: 5, 5: 6, 6: 0}

    # Validate
    if not 0 < len(A_   ) < 11:
        raise ValueError('Must be 10 characters long'   )

    # Get month
    _lowerCAmelCase       :   List[str]  =    int(date_input[0] + date_input[1]   )
    # Validate
    if not 0 < m < 13:
        raise ValueError('Month must be between 1 - 12'   )

    _lowerCAmelCase       :   Dict  =    date_input[2]
    # Validate
    if sep_a not in ["-", "/"]:
        raise ValueError('Date separator must be \'-\' or \'/\''   )

    # Get day
    _lowerCAmelCase       :   Dict  =    int(date_input[3] + date_input[4]   )
    # Validate
    if not 0 < d < 32:
        raise ValueError('Date must be between 1 - 31'   )

    # Get second separator
    _lowerCAmelCase       :   Optional[Any]  =    date_input[5]
    # Validate
    if sep_a not in ["-", "/"]:
        raise ValueError('Date separator must be \'-\' or \'/\''   )

    # Get year
    _lowerCAmelCase       :   Optional[Any]  =    int(date_input[6] + date_input[7] + date_input[8] + date_input[9]   )
    # Arbitrary year range
    if not 45 < y < 8500:
        raise ValueError(
            'Year out of range. There has to be some sort of limit...right?'   )

    # Get datetime obj for validation
    _lowerCAmelCase       :   Union[str, Any]  =    datetime.date(int(A_   ) ,   int(A_   ) ,   int(A_   )   )

    # Start math
    if m <= 2:
        _lowerCAmelCase       :   Any  =    y - 1
        _lowerCAmelCase       :   str  =    m + 12
    # maths var
    _lowerCAmelCase       :   Tuple  =    int(str(A_   )[:2]   )
    _lowerCAmelCase       :   Tuple  =    int(str(A_   )[2:]   )
    _lowerCAmelCase       :   Union[str, Any]  =    int(2.6 * m - 5.39   )
    _lowerCAmelCase       :   Optional[Any]  =    int(c / 4   )
    _lowerCAmelCase       :   Tuple  =    int(k / 4   )
    _lowerCAmelCase       :   Optional[Any]  =    int(d + k   )
    _lowerCAmelCase       :   List[str]  =    int(t + u + v + x   )
    _lowerCAmelCase       :   List[str]  =    int(z - (2 * c)   )
    _lowerCAmelCase       :   int  =    round(w % 7   )
    # End math

    # Validate math
    if f != convert_datetime_days[dt_ck.weekday()]:
        raise AssertionError('The date was evaluated incorrectly. Contact developer.'   )

    # Response
    _lowerCAmelCase       :   Any  =    f"""Your date {date_input}, is a {days[str(A_   )]}!"""
    return response


if __name__ == "__main__":
 import doctest

 doctest.testmod()
 _lowerCAmelCase						=		argparse.ArgumentParser(
     description=(
         """Find out what day of the week nearly any date is or was. Enter """
         """date as a string in the mm-dd-yyyy or mm/dd/yyyy format"""
     )
 )
 parser.add_argument(
     """date_input""", type=str, help="""Date as a string (mm-dd-yyyy or mm/dd/yyyy)"""
 )
 _lowerCAmelCase						=		parser.parse_args()
 zeller(args.date_input)


"""simple docstring"""






import inspect
import os
import unittest

import torch

import accelerate
from accelerate import Accelerator
from accelerate.test_utils import execute_subprocess_async, require_multi_gpu
from accelerate.utils import patch_environment







class 	__UpperCamelCase    (    unittest.TestCase						):

  def __lowerCamelCase		(		self      ):
      '''simple docstring'''

      _lowerCAmelCase       :   Dict  =    inspect.getfile(accelerate.test_utils      )
      _lowerCAmelCase       :   Union[str, Any]  =    os.path.sep.join(mod_file.split(os.path.sep      )[:-1] + ['scripts', 'test_script.py']      )
      _lowerCAmelCase       :   int  =    os.path.sep.join(
          mod_file.split(os.path.sep      )[:-1] + ['scripts', 'test_distributed_data_loop.py']      )
      _lowerCAmelCase       :   Optional[Any]  =    os.path.sep.join(mod_file.split(os.path.sep      )[:-1] + ['scripts', 'test_ops.py']      )

  @require_multi_gpu
  def __lowerCamelCase		(		self      ):
      '''simple docstring'''

      print(F"""Found {torch.cuda.device_count()} devices."""      )
      _lowerCAmelCase       :   int  =    ['torchrun', F"""--nproc_per_node={torch.cuda.device_count()}""", self.test_file_path]
      with patch_environment(omp_num_threads=1      ):
          execute_subprocess_async(_A    ,env=os.environ.copy()      )

  @require_multi_gpu
  def __lowerCamelCase		(		self      ):
      '''simple docstring'''

      print(F"""Found {torch.cuda.device_count()} devices."""      )
      _lowerCAmelCase       :   str  =    ['torchrun', F"""--nproc_per_node={torch.cuda.device_count()}""", self.operation_file_path]
      print(F"""Command: {cmd}"""      )
      with patch_environment(omp_num_threads=1      ):
          execute_subprocess_async(_A    ,env=os.environ.copy()      )

  @require_multi_gpu
  def __lowerCamelCase		(		self      ):
      '''simple docstring'''

      _lowerCAmelCase       :   List[Any]  =    ['torchrun', F"""--nproc_per_node={torch.cuda.device_count()}""", inspect.getfile(self.__class__      )]
      with patch_environment(omp_num_threads=1      ):
          execute_subprocess_async(_A    ,env=os.environ.copy()      )







  @require_multi_gpu
  def __lowerCamelCase		(		self      ):
      '''simple docstring'''

      print(F"""Found {torch.cuda.device_count()} devices, using 2 devices only"""      )
      _lowerCAmelCase       :   Tuple  =    ['torchrun', F"""--nproc_per_node={torch.cuda.device_count()}""", self.data_loop_file_path]
      with patch_environment(omp_num_threads=1    ,cuda_visible_devices='0,1'      ):
          execute_subprocess_async(_A    ,env=os.environ.copy()      )


if __name__ == "__main__":
 _lowerCAmelCase						=		Accelerator()
 _lowerCAmelCase						=		(accelerator.state.process_index + 2, 1_0)
 _lowerCAmelCase						=		torch.randint(0, 1_0, shape).to(accelerator.device)

 _lowerCAmelCase						=		""""""

 _lowerCAmelCase						=		accelerator.pad_across_processes(tensor)
 if tensora.shape[0] != accelerator.state.num_processes + 1:
  error_msg += F"Found shape {tensora.shape} but should have {accelerator.state.num_processes + 1} at dim 0."
 if not torch.equal(tensora[: accelerator.state.process_index + 2], tensor):
  error_msg += "Tensors have different values."
 if not torch.all(tensora[accelerator.state.process_index + 2 :] == 0):
  error_msg += "Padding was not done with the right value (0)."

 _lowerCAmelCase						=		accelerator.pad_across_processes(tensor, pad_first=True)
 if tensora.shape[0] != accelerator.state.num_processes + 1:
  error_msg += F"Found shape {tensora.shape} but should have {accelerator.state.num_processes + 1} at dim 0."
 _lowerCAmelCase						=		accelerator.state.num_processes - accelerator.state.process_index - 1
 if not torch.equal(tensora[index:], tensor):
  error_msg += "Tensors have different values."
 if not torch.all(tensora[:index] == 0):
  error_msg += "Padding was not done with the right value (0)."

 # Raise error at the end to make sure we don't stop at the first failure.
 if len(error_msg) > 0:
  raise ValueError(error_msg)





