code: 
  
  
  
  
  
  import logging
  
  # standard libraries
  import sys
  
  import numpy as np
  import pytest  # type: ignore
  
  # Custom/local libraries
  from matrix import matrix_operation as matop
  
  UpperCAmelCase			:			Union[str, Any]	  = [[12, 10], [3, 9]]
  UpperCAmelCase			:			List[Any]	  = [[3, 4], [7, 4]]
  UpperCAmelCase			:			List[Any]	  = [[3, 0, 2], [2, 0, -2], [0, 1, 1]]
  UpperCAmelCase			:			Dict	  = [[3, 0, -2], [2, 0, 2], [0, 1, 1]]
  UpperCAmelCase			:			List[Any]	  = [[3, 0, 2], [2, 0, -2], [0, 1, 1], [2, 0, -2]]
  UpperCAmelCase			:			Dict	  = [1]
  UpperCAmelCase			:			List[str]	  = [2]
  
  UpperCAmelCase			:			Any	  = logging.getLogger()
  UpperCAmelCase			:			Union[str, Any]	  = logging.DEBUG
  UpperCAmelCase			:			List[Any]	  = logging.StreamHandler(sys.stdout)
  logger.addHandler(stream_handler)
  @pytest.mark.mat_ops
  @pytest.mark.parametrize(
      ("mat1", "mat2") , [(mat_a, mat_b), (mat_c, mat_d), (mat_d, mat_e), (mat_f, mat_h)]		)
  def   _A (	SCREAMING_SNAKE_CASE  :     str , SCREAMING_SNAKE_CASE  :     List[Any]		):
  
  
  
  
  
    """simple docstring"""
  
  
  
    if (np.array(SCREAMING_SNAKE_CASE		)).shape < (2, 2) or (np.array(SCREAMING_SNAKE_CASE		)).shape < (2, 2):
      with pytest.raises(SCREAMING_SNAKE_CASE		):
        logger.info(f'''\n\t{test_addition.__name__} returned integer'''		)
        matop.add(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE		)
    elif (np.array(SCREAMING_SNAKE_CASE		)).shape == (np.array(SCREAMING_SNAKE_CASE		)).shape:
      logger.info(f'''\n\t{test_addition.__name__} with same matrix dims'''		)
      a__			:      List[Any]            =(np.array(SCREAMING_SNAKE_CASE		) + np.array(SCREAMING_SNAKE_CASE		)).tolist()
      a__			:      List[Any]            =matop.add(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE		)
      assert theo == act
    else:
      with pytest.raises(SCREAMING_SNAKE_CASE		):
        logger.info(f'''\n\t{test_addition.__name__} with different matrix dims'''		)
        matop.add(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE		)
  @pytest.mark.mat_ops
  @pytest.mark.parametrize(
      ("mat1", "mat2") , [(mat_a, mat_b), (mat_c, mat_d), (mat_d, mat_e), (mat_f, mat_h)]		)
  def   _A (	SCREAMING_SNAKE_CASE  :     Dict , SCREAMING_SNAKE_CASE  :     str		):
  
  
  
  
  
    """simple docstring"""
  
  
  
    if (np.array(SCREAMING_SNAKE_CASE		)).shape < (2, 2) or (np.array(SCREAMING_SNAKE_CASE		)).shape < (2, 2):
      with pytest.raises(SCREAMING_SNAKE_CASE		):
        logger.info(f'''\n\t{test_subtraction.__name__} returned integer'''		)
        matop.subtract(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE		)
    elif (np.array(SCREAMING_SNAKE_CASE		)).shape == (np.array(SCREAMING_SNAKE_CASE		)).shape:
      logger.info(f'''\n\t{test_subtraction.__name__} with same matrix dims'''		)
      a__			:      Union[str, Any]            =(np.array(SCREAMING_SNAKE_CASE		) - np.array(SCREAMING_SNAKE_CASE		)).tolist()
      a__			:      str            =matop.subtract(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE		)
      assert theo == act
    else:
      with pytest.raises(SCREAMING_SNAKE_CASE		):
        logger.info(f'''\n\t{test_subtraction.__name__} with different matrix dims'''		)
        assert matop.subtract(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE		)
  @pytest.mark.mat_ops
  @pytest.mark.parametrize(
      ("mat1", "mat2") , [(mat_a, mat_b), (mat_c, mat_d), (mat_d, mat_e), (mat_f, mat_h)]		)
  def   _A (	SCREAMING_SNAKE_CASE  :     List[Any] , SCREAMING_SNAKE_CASE  :     Optional[Any]		):
  
  
  
  
  
    """simple docstring"""
  
  
  
    if (np.array(SCREAMING_SNAKE_CASE		)).shape < (2, 2) or (np.array(SCREAMING_SNAKE_CASE		)).shape < (2, 2):
      logger.info(f'''\n\t{test_multiplication.__name__} returned integer'''		)
      with pytest.raises(SCREAMING_SNAKE_CASE		):
        matop.add(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE		)
    elif (np.array(SCREAMING_SNAKE_CASE		)).shape == (np.array(SCREAMING_SNAKE_CASE		)).shape:
      logger.info(f'''\n\t{test_multiplication.__name__} meets dim requirements'''		)
      a__			:      Tuple            =(np.matmul(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE		)).tolist()
      a__			:      Dict            =matop.multiply(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE		)
      assert theo == act
    else:
      with pytest.raises(SCREAMING_SNAKE_CASE		):
        logger.info(
            f'''\n\t{test_multiplication.__name__} does not meet dim requirements'''		)
        assert matop.subtract(SCREAMING_SNAKE_CASE , SCREAMING_SNAKE_CASE		)
  @pytest.mark.mat_ops
  def   _A (	):
  
  
  
  
  
    """simple docstring"""
  
  
  
    a__			:      Union[str, Any]            =(3.5 * np.array(SCREAMING_SNAKE_CASE		)).tolist()
    a__			:      Any            =matop.scalar_multiply(SCREAMING_SNAKE_CASE , 3.5		)
    assert theo == act
  @pytest.mark.mat_ops
  def   _A (	):
  
  
  
  
  
    """simple docstring"""
  
  
  
    a__			:      Union[str, Any]            =(np.identity(5		)).tolist()
    a__			:      Optional[Any]            =matop.identity(5		)
    assert theo == act
  
  
  
  
  
  @pytest.mark.mat_ops
  @pytest.mark.parametrize("mat" , [mat_a, mat_b, mat_c, mat_d, mat_e, mat_f]		)
  def   _A (	SCREAMING_SNAKE_CASE  :     str		):
  
  
  
  
  
    """simple docstring"""
  
  
  
    if (np.array(SCREAMING_SNAKE_CASE		)).shape < (2, 2):
      with pytest.raises(SCREAMING_SNAKE_CASE		):
        logger.info(f'''\n\t{test_transpose.__name__} returned integer'''		)
        matop.transpose(SCREAMING_SNAKE_CASE		)
    else:
      a__			:      int            =(np.transpose(SCREAMING_SNAKE_CASE		)).tolist()
      a__			:      Dict            =matop.transpose(SCREAMING_SNAKE_CASE , return_map=SCREAMING_SNAKE_CASE		)
      assert theo == act
  
  
  
  
  
  
  
style_context: 
  
  
  
  
  
  import importlib
  import sys
  from argparse import REMAINDER, ArgumentParser
  from pathlib import Path
  
  import torch_xla.distributed.xla_multiprocessing as xmp
  def   _A (	):
  
  
  
  
  
    """simple docstring"""
  
  
  
    a__			:      Optional[int]            =ArgumentParser(
        description=(
            "PyTorch TPU distributed training launch helper utility that will spawn up multiple distributed processes"
        )		)
  
    # Optional arguments for the launch helper
    parser.add_argument("--num_cores" , type=SCREAMING_SNAKE_CASE , default=1 , help="Number of TPU cores to use (1 or 8)."		)
  
    # positional
    parser.add_argument(
        "training_script" , type=SCREAMING_SNAKE_CASE , help=(
            "The full path to the single TPU training "
            "program/script to be launched in parallel, "
            "followed by all the arguments for the "
            "training script"
        ) , )
  
    # rest from the training program
    parser.add_argument("training_script_args" , nargs=SCREAMING_SNAKE_CASE		)
  
    return parser.parse_args()
  def   _A (	):
  
  
  
  
  
    """simple docstring"""
  
  
  
    a__			:      Optional[Any]            =parse_args()
  
    # Import training_script as a module.
    a__			:      Tuple            =Path(args.training_script		)
    sys.path.append(str(script_fpath.parent.resolve()		)		)
    a__			:      Tuple            =script_fpath.stem
    a__			:      Any            =importlib.import_module(SCREAMING_SNAKE_CASE		)
  
    # Patch sys.argv
    a__			:      List[str]            =[args.training_script] + args.training_script_args + ["--tpu_num_cores", str(args.num_cores		)]
  
    xmp.spawn(mod._mp_fn , args=() , nprocs=args.num_cores		)
  
  
  if __name__ == "__main__":
       main()
  
  
  
  
  
  
  