

'''simple docstring'''






import random
import unittest

from torch.utils.data import BatchSampler, DataLoader, IterableDataset

from accelerate import Accelerator
from accelerate.data_loader import (
    BatchSamplerShard,
    DataLoaderDispatcher,
    DataLoaderShard,
    IterableDatasetShard,
    SkipBatchSampler,
    SkipDataLoader,
    skip_first_batches,
)






class      lowercase_      (lowerCamelCase__ ):




  """simple docstring"""




  def __init__( self  :	str   ,lowercase__  :	int=0.0_1   ,lowercase__  :	List[Any]=1_0_0_0     ):
   __lowercase				    =					p_stop
   __lowercase				    =					max_length






  def __iter__( self  :	List[str]     ):
   __lowercase				    =					0
   __lowercase				    =					False
   while not stop and count < self.max_length:
    yield count
    count += 1
    __lowercase				    =					random.random() < self.p_stop






class      lowercase_      (unittest.TestCase ):




  """simple docstring"""




  def    SCREAMING_SNAKE_CASE ( self  :	Optional[int]   ,lowercase__  :	Dict   ,lowercase__  :	int   ,lowercase__  :	Tuple=False   ,lowercase__  :	Optional[Any]=True     ):
   __lowercase				    =					[
       BatchSamplerShard(lowercase__   ,2   ,lowercase__   ,split_batches=lowercase__   ,even_batches=lowercase__     )
       for i in range(2     )
   ]
   __lowercase				    =					[list(lowercase__     ) for batch_sampler_shard in batch_sampler_shards]
   if not split_batches:
    self.assertListEqual([len(lowercase__     ) for shard in batch_sampler_shards]   ,[len(lowercase__     ) for e in expected]     )
   self.assertListEqual(lowercase__   ,lowercase__     )






  def    SCREAMING_SNAKE_CASE ( self  :	Union[str, Any]     ):
   # Check the shards when the dataset is a round multiple of total batch size.
   __lowercase				    =					BatchSampler(range(2_4     )   ,batch_size=3   ,drop_last=lowercase__     )
   __lowercase				    =					[
       [[0, 1, 2], [6, 7, 8], [1_2, 1_3, 1_4], [1_8, 1_9, 2_0]],
       [[3, 4, 5], [9, 1_0, 1_1], [1_5, 1_6, 1_7], [2_1, 2_2, 2_3]],
   ]
   self.check_batch_sampler_shards(lowercase__   ,lowercase__     )

   __lowercase				    =					BatchSampler(range(2_4     )   ,batch_size=3   ,drop_last=lowercase__     )
   # Expected shouldn't change
   self.check_batch_sampler_shards(lowercase__   ,lowercase__     )

   # Check the shards when the dataset is a round multiple of batch size but not total batch size.
   __lowercase				    =					BatchSampler(range(2_1     )   ,batch_size=3   ,drop_last=lowercase__     )
   __lowercase				    =					[
       [[0, 1, 2], [6, 7, 8], [1_2, 1_3, 1_4], [1_8, 1_9, 2_0]],
       [[3, 4, 5], [9, 1_0, 1_1], [1_5, 1_6, 1_7], [0, 1, 2]],
   ]
   self.check_batch_sampler_shards(lowercase__   ,lowercase__     )

   __lowercase				    =					BatchSampler(range(2_1     )   ,batch_size=3   ,drop_last=lowercase__     )
   __lowercase				    =					[
       [[0, 1, 2], [6, 7, 8], [1_2, 1_3, 1_4]],
       [[3, 4, 5], [9, 1_0, 1_1], [1_5, 1_6, 1_7]],
   ]
   self.check_batch_sampler_shards(lowercase__   ,lowercase__     )

   # Check the shards when the dataset is not a round multiple of batch size but has a multiple of
   # num_processes batch.
   __lowercase				    =					BatchSampler(range(2_2     )   ,batch_size=3   ,drop_last=lowercase__     )
   __lowercase				    =					[
       [[0, 1, 2], [6, 7, 8], [1_2, 1_3, 1_4], [1_8, 1_9, 2_0]],
       [[3, 4, 5], [9, 1_0, 1_1], [1_5, 1_6, 1_7], [2_1, 0, 1]],
   ]
   self.check_batch_sampler_shards(lowercase__   ,lowercase__     )

   __lowercase				    =					BatchSampler(range(2_2     )   ,batch_size=3   ,drop_last=lowercase__     )
   __lowercase				    =					[
       [[0, 1, 2], [6, 7, 8], [1_2, 1_3, 1_4]],
       [[3, 4, 5], [9, 1_0, 1_1], [1_5, 1_6, 1_7]],
   ]
   self.check_batch_sampler_shards(lowercase__   ,lowercase__     )

   # Check the shards when the dataset is not a round multiple of batch size but and has not a multiple of
   # num_processes batch.
   __lowercase				    =					BatchSampler(range(2_0     )   ,batch_size=3   ,drop_last=lowercase__     )
   __lowercase				    =					[
       [[0, 1, 2], [6, 7, 8], [1_2, 1_3, 1_4], [1_8, 1_9, 0]],
       [[3, 4, 5], [9, 1_0, 1_1], [1_5, 1_6, 1_7], [1, 2, 3]],
   ]
   self.check_batch_sampler_shards(lowercase__   ,lowercase__     )

   __lowercase				    =					BatchSampler(range(2_0     )   ,batch_size=3   ,drop_last=lowercase__     )
   __lowercase				    =					[
       [[0, 1, 2], [6, 7, 8], [1_2, 1_3, 1_4]],
       [[3, 4, 5], [9, 1_0, 1_1], [1_5, 1_6, 1_7]],
   ]
   self.check_batch_sampler_shards(lowercase__   ,lowercase__     )

   # Check the shards when the dataset is very small.
   __lowercase				    =					BatchSampler(range(2     )   ,batch_size=3   ,drop_last=lowercase__     )
   __lowercase				    =					[[[0, 1, 0]], [[1, 0, 1]]]
   self.check_batch_sampler_shards(lowercase__   ,lowercase__     )

   __lowercase				    =					BatchSampler(range(2     )   ,batch_size=3   ,drop_last=lowercase__     )
   __lowercase				    =					[[], []]
   self.check_batch_sampler_shards(lowercase__   ,lowercase__     )






  def    SCREAMING_SNAKE_CASE ( self  :	Tuple     ):
   # Check the shards when the dataset is a round multiple of batch size.
   __lowercase				    =					BatchSampler(range(2_4     )   ,batch_size=4   ,drop_last=lowercase__     )
   __lowercase				    =					[
       [[0, 1], [4, 5], [8, 9], [1_2, 1_3], [1_6, 1_7], [2_0, 2_1]],
       [[2, 3], [6, 7], [1_0, 1_1], [1_4, 1_5], [1_8, 1_9], [2_2, 2_3]],
   ]
   self.check_batch_sampler_shards(lowercase__   ,lowercase__   ,split_batches=lowercase__     )

   __lowercase				    =					BatchSampler(range(2_4     )   ,batch_size=4   ,drop_last=lowercase__     )
   # Expected shouldn't change
   self.check_batch_sampler_shards(lowercase__   ,lowercase__   ,split_batches=lowercase__     )

   # Check the shards when the dataset is not a round multiple of batch size.
   __lowercase				    =					BatchSampler(range(2_2     )   ,batch_size=4   ,drop_last=lowercase__     )
   __lowercase				    =					[
       [[0, 1], [4, 5], [8, 9], [1_2, 1_3], [1_6, 1_7], [2_0, 2_1]],
       [[2, 3], [6, 7], [1_0, 1_1], [1_4, 1_5], [1_8, 1_9], [0, 1]],
   ]
   self.check_batch_sampler_shards(lowercase__   ,lowercase__   ,split_batches=lowercase__     )

   __lowercase				    =					BatchSampler(range(2_2     )   ,batch_size=4   ,drop_last=lowercase__     )
   __lowercase				    =					[
       [[0, 1], [4, 5], [8, 9], [1_2, 1_3], [1_6, 1_7]],
       [[2, 3], [6, 7], [1_0, 1_1], [1_4, 1_5], [1_8, 1_9]],
   ]
   self.check_batch_sampler_shards(lowercase__   ,lowercase__   ,split_batches=lowercase__     )

   # Check the shards when the dataset is not a round multiple of batch size or num_processes.
   __lowercase				    =					BatchSampler(range(2_1     )   ,batch_size=4   ,drop_last=lowercase__     )
   __lowercase				    =					[
       [[0, 1], [4, 5], [8, 9], [1_2, 1_3], [1_6, 1_7], [2_0, 0]],
       [[2, 3], [6, 7], [1_0, 1_1], [1_4, 1_5], [1_8, 1_9], [1, 2]],
   ]
   self.check_batch_sampler_shards(lowercase__   ,lowercase__   ,split_batches=lowercase__     )

   __lowercase				    =					BatchSampler(range(2_1     )   ,batch_size=4   ,drop_last=lowercase__     )
   __lowercase				    =					[
       [[0, 1], [4, 5], [8, 9], [1_2, 1_3], [1_6, 1_7]],
       [[2, 3], [6, 7], [1_0, 1_1], [1_4, 1_5], [1_8, 1_9]],
   ]
   self.check_batch_sampler_shards(lowercase__   ,lowercase__   ,split_batches=lowercase__     )

   # Check the shards when the dataset is very small.
   __lowercase				    =					BatchSampler(range(2     )   ,batch_size=4   ,drop_last=lowercase__     )
   __lowercase				    =					[[[0, 1]], [[0, 1]]]
   self.check_batch_sampler_shards(lowercase__   ,lowercase__   ,split_batches=lowercase__     )

   __lowercase				    =					BatchSampler(range(2     )   ,batch_size=4   ,drop_last=lowercase__     )
   __lowercase				    =					[[], []]
   self.check_batch_sampler_shards(lowercase__   ,lowercase__   ,split_batches=lowercase__     )






  def    SCREAMING_SNAKE_CASE ( self  :	int     ):
   # Check the shards when the dataset is a round multiple of total batch size.
   __lowercase				    =					BatchSampler(range(2_4     )   ,batch_size=3   ,drop_last=lowercase__     )
   __lowercase				    =					[
       [[0, 1, 2], [6, 7, 8], [1_2, 1_3, 1_4], [1_8, 1_9, 2_0]],
       [[3, 4, 5], [9, 1_0, 1_1], [1_5, 1_6, 1_7], [2_1, 2_2, 2_3]],
   ]
   self.check_batch_sampler_shards(lowercase__   ,lowercase__   ,even_batches=lowercase__     )

   __lowercase				    =					BatchSampler(range(2_4     )   ,batch_size=3   ,drop_last=lowercase__     )
   # Expected shouldn't change
   self.check_batch_sampler_shards(lowercase__   ,lowercase__   ,even_batches=lowercase__     )

   # Check the shards when the dataset is a round multiple of batch size but not total batch size.
   __lowercase				    =					BatchSampler(range(2_1     )   ,batch_size=3   ,drop_last=lowercase__     )
   __lowercase				    =					[
       [[0, 1, 2], [6, 7, 8], [1_2, 1_3, 1_4], [1_8, 1_9, 2_0]],
       [[3, 4, 5], [9, 1_0, 1_1], [1_5, 1_6, 1_7]],
   ]
   self.check_batch_sampler_shards(lowercase__   ,lowercase__   ,even_batches=lowercase__     )

   __lowercase				    =					BatchSampler(range(2_1     )   ,batch_size=3   ,drop_last=lowercase__     )
   __lowercase				    =					[
       [[0, 1, 2], [6, 7, 8], [1_2, 1_3, 1_4]],
       [[3, 4, 5], [9, 1_0, 1_1], [1_5, 1_6, 1_7]],
   ]
   self.check_batch_sampler_shards(lowercase__   ,lowercase__   ,even_batches=lowercase__     )

   # Check the shards when the dataset is not a round multiple of batch size but has a multiple of
   # num_processes batch.
   __lowercase				    =					BatchSampler(range(2_2     )   ,batch_size=3   ,drop_last=lowercase__     )
   __lowercase				    =					[
       [[0, 1, 2], [6, 7, 8], [1_2, 1_3, 1_4], [1_8, 1_9, 2_0]],
       [[3, 4, 5], [9, 1_0, 1_1], [1_5, 1_6, 1_7], [2_1]],
   ]
   self.check_batch_sampler_shards(lowercase__   ,lowercase__   ,even_batches=lowercase__     )

   __lowercase				    =					BatchSampler(range(2_2     )   ,batch_size=3   ,drop_last=lowercase__     )
   __lowercase				    =					[
       [[0, 1, 2], [6, 7, 8], [1_2, 1_3, 1_4]],
       [[3, 4, 5], [9, 1_0, 1_1], [1_5, 1_6, 1_7]],
   ]
   self.check_batch_sampler_shards(lowercase__   ,lowercase__   ,even_batches=lowercase__     )

   # Check the shards when the dataset is not a round multiple of batch size but and has not a multiple of
   # num_processes batch.
   __lowercase				    =					BatchSampler(range(2_0     )   ,batch_size=3   ,drop_last=lowercase__     )
   __lowercase				    =					[
       [[0, 1, 2], [6, 7, 8], [1_2, 1_3, 1_4], [1_8, 1_9]],
       [[3, 4, 5], [9, 1_0, 1_1], [1_5, 1_6, 1_7]],
   ]
   self.check_batch_sampler_shards(lowercase__   ,lowercase__   ,even_batches=lowercase__     )

   __lowercase				    =					BatchSampler(range(2_0     )   ,batch_size=3   ,drop_last=lowercase__     )
   __lowercase				    =					[
       [[0, 1, 2], [6, 7, 8], [1_2, 1_3, 1_4]],
       [[3, 4, 5], [9, 1_0, 1_1], [1_5, 1_6, 1_7]],
   ]
   self.check_batch_sampler_shards(lowercase__   ,lowercase__   ,even_batches=lowercase__     )

   # Check the shards when the dataset is very small.
   __lowercase				    =					BatchSampler(range(2     )   ,batch_size=3   ,drop_last=lowercase__     )
   __lowercase				    =					[[[0, 1]], []]
   self.check_batch_sampler_shards(lowercase__   ,lowercase__   ,even_batches=lowercase__     )

   __lowercase				    =					BatchSampler(range(2     )   ,batch_size=3   ,drop_last=lowercase__     )
   __lowercase				    =					[[], []]
   self.check_batch_sampler_shards(lowercase__   ,lowercase__   ,even_batches=lowercase__     )






  def    SCREAMING_SNAKE_CASE ( self  :	Any     ):
   # Check the shards when the dataset is a round multiple of batch size.
   __lowercase				    =					BatchSampler(range(2_4     )   ,batch_size=4   ,drop_last=lowercase__     )
   __lowercase				    =					[
       [[0, 1], [4, 5], [8, 9], [1_2, 1_3], [1_6, 1_7], [2_0, 2_1]],
       [[2, 3], [6, 7], [1_0, 1_1], [1_4, 1_5], [1_8, 1_9], [2_2, 2_3]],
   ]
   self.check_batch_sampler_shards(lowercase__   ,lowercase__   ,split_batches=lowercase__   ,even_batches=lowercase__     )

   __lowercase				    =					BatchSampler(range(2_4     )   ,batch_size=4   ,drop_last=lowercase__     )
   # Expected shouldn't change
   self.check_batch_sampler_shards(lowercase__   ,lowercase__   ,split_batches=lowercase__   ,even_batches=lowercase__     )

   # Check the shards when the dataset is not a round multiple of batch size.
   __lowercase				    =					BatchSampler(range(2_2     )   ,batch_size=4   ,drop_last=lowercase__     )
   __lowercase				    =					[
       [[0, 1], [4, 5], [8, 9], [1_2, 1_3], [1_6, 1_7], [2_0, 2_1]],
       [[2, 3], [6, 7], [1_0, 1_1], [1_4, 1_5], [1_8, 1_9]],
   ]
   self.check_batch_sampler_shards(lowercase__   ,lowercase__   ,split_batches=lowercase__   ,even_batches=lowercase__     )

   __lowercase				    =					BatchSampler(range(2_2     )   ,batch_size=4   ,drop_last=lowercase__     )
   __lowercase				    =					[
       [[0, 1], [4, 5], [8, 9], [1_2, 1_3], [1_6, 1_7]],
       [[2, 3], [6, 7], [1_0, 1_1], [1_4, 1_5], [1_8, 1_9]],
   ]
   self.check_batch_sampler_shards(lowercase__   ,lowercase__   ,split_batches=lowercase__   ,even_batches=lowercase__     )

   # Check the shards when the dataset is not a round multiple of batch size or num_processes.
   __lowercase				    =					BatchSampler(range(2_1     )   ,batch_size=4   ,drop_last=lowercase__     )
   __lowercase				    =					[
       [[0, 1], [4, 5], [8, 9], [1_2, 1_3], [1_6, 1_7], [2_0]],
       [[2, 3], [6, 7], [1_0, 1_1], [1_4, 1_5], [1_8, 1_9]],
   ]
   self.check_batch_sampler_shards(lowercase__   ,lowercase__   ,split_batches=lowercase__   ,even_batches=lowercase__     )

   __lowercase				    =					BatchSampler(range(2_1     )   ,batch_size=4   ,drop_last=lowercase__     )
   __lowercase				    =					[
       [[0, 1], [4, 5], [8, 9], [1_2, 1_3], [1_6, 1_7]],
       [[2, 3], [6, 7], [1_0, 1_1], [1_4, 1_5], [1_8, 1_9]],
   ]
   self.check_batch_sampler_shards(lowercase__   ,lowercase__   ,split_batches=lowercase__   ,even_batches=lowercase__     )

   # Check the shards when the dataset is very small.
   __lowercase				    =					BatchSampler(range(2     )   ,batch_size=4   ,drop_last=lowercase__     )
   __lowercase				    =					[[[0, 1]], []]
   self.check_batch_sampler_shards(lowercase__   ,lowercase__   ,split_batches=lowercase__   ,even_batches=lowercase__     )

   __lowercase				    =					BatchSampler(range(2     )   ,batch_size=4   ,drop_last=lowercase__     )
   __lowercase				    =					[[], []]
   self.check_batch_sampler_shards(lowercase__   ,lowercase__   ,split_batches=lowercase__   ,even_batches=lowercase__     )






  def    SCREAMING_SNAKE_CASE ( self  :	Union[str, Any]     ):
   __lowercase				    =					[[0, 1, 2], [3, 4], [5, 6, 7, 8], [9, 1_0, 1_1], [1_2, 1_3]]
   __lowercase				    =					[BatchSamplerShard(lowercase__   ,2   ,lowercase__   ,even_batches=lowercase__     ) for i in range(2     )]

   self.assertEqual(len(batch_sampler_shards[0]     )   ,3     )
   self.assertEqual(len(batch_sampler_shards[1]     )   ,2     )

   self.assertListEqual(list(batch_sampler_shards[0]     )   ,[[0, 1, 2], [5, 6, 7, 8], [1_2, 1_3]]     )
   self.assertListEqual(list(batch_sampler_shards[1]     )   ,[[3, 4], [9, 1_0, 1_1]]     )






  def    SCREAMING_SNAKE_CASE ( self  :	Optional[int]   ,lowercase__  :	Any   ,lowercase__  :	Optional[int]   ,lowercase__  :	List[str]   ,lowercase__  :	Tuple=False   ,lowercase__  :	int=2   ,lowercase__  :	Tuple=False     ):
   random.seed(lowercase__     )
   __lowercase				    =					list(lowercase__     )

   __lowercase				    =					[
       IterableDatasetShard(
           lowercase__   ,batch_size=lowercase__   ,drop_last=lowercase__   ,num_processes=lowercase__   ,process_index=lowercase__   ,split_batches=lowercase__   ,)
       for i in range(lowercase__     )
   ]
   __lowercase				    =					[]
   for iterable_dataset_shard in iterable_dataset_shards:
    # Since our random iterable dataset will be... random... we need to use a seed to get reproducible results.
    random.seed(lowercase__     )
    iterable_dataset_lists.append(list(lowercase__     )     )

   __lowercase				    =					batch_size // num_processes if split_batches else batch_size
   # All iterable dataset shard should have the same length, a round multiple of shard_batch_size
   __lowercase				    =					iterable_dataset_lists[0]
   for l in iterable_dataset_lists[1:]:
    self.assertEqual(len(lowercase__     )   ,len(lowercase__     )     )
    self.assertTrue(len(lowercase__     ) % shard_batch_size == 0     )

   __lowercase				    =					[]
   for idx in range(0   ,len(lowercase__     )   ,lowercase__     ):
    for l in iterable_dataset_lists:
     observed += l[idx : idx + shard_batch_size]

   if not drop_last:
    while len(lowercase__     ) < len(lowercase__     ):
     reference += reference
   self.assertListEqual(lowercase__   ,reference[: len(lowercase__     )]     )






  def    SCREAMING_SNAKE_CASE ( self  :	str     ):
   __lowercase				    =					4_2
   __lowercase				    =					RandomIterableDataset()

   self.check_iterable_dataset_shards(lowercase__   ,lowercase__   ,batch_size=4   ,drop_last=lowercase__   ,split_batches=lowercase__     )
   self.check_iterable_dataset_shards(lowercase__   ,lowercase__   ,batch_size=4   ,drop_last=lowercase__   ,split_batches=lowercase__     )
   self.check_iterable_dataset_shards(lowercase__   ,lowercase__   ,batch_size=4   ,drop_last=lowercase__   ,split_batches=lowercase__     )
   self.check_iterable_dataset_shards(lowercase__   ,lowercase__   ,batch_size=4   ,drop_last=lowercase__   ,split_batches=lowercase__     )

   # Edge case with a very small dataset
   __lowercase				    =					RandomIterableDataset(max_length=2     )

   self.check_iterable_dataset_shards(lowercase__   ,lowercase__   ,batch_size=4   ,drop_last=lowercase__   ,split_batches=lowercase__     )
   self.check_iterable_dataset_shards(lowercase__   ,lowercase__   ,batch_size=4   ,drop_last=lowercase__   ,split_batches=lowercase__     )
   self.check_iterable_dataset_shards(lowercase__   ,lowercase__   ,batch_size=4   ,drop_last=lowercase__   ,split_batches=lowercase__     )
   self.check_iterable_dataset_shards(lowercase__   ,lowercase__   ,batch_size=4   ,drop_last=lowercase__   ,split_batches=lowercase__     )






  def    SCREAMING_SNAKE_CASE ( self  :	List[str]     ):
   __lowercase				    =					BatchSampler(range(1_6     )   ,batch_size=4   ,drop_last=lowercase__     )
   __lowercase				    =					SkipBatchSampler(lowercase__   ,2     )
   self.assertListEqual(list(lowercase__     )   ,[[8, 9, 1_0, 1_1], [1_2, 1_3, 1_4, 1_5]]     )






  def    SCREAMING_SNAKE_CASE ( self  :	str     ):
   __lowercase				    =					SkipDataLoader(list(range(1_6     )     )   ,batch_size=4   ,skip_batches=2     )
   self.assertListEqual([t.tolist() for t in dataloader]   ,[[8, 9, 1_0, 1_1], [1_2, 1_3, 1_4, 1_5]]     )






  def    SCREAMING_SNAKE_CASE ( self  :	Optional[int]     ):
   __lowercase				    =					DataLoader(list(range(1_6     )     )   ,batch_size=4     )
   __lowercase				    =					skip_first_batches(lowercase__   ,num_batches=2     )
   self.assertListEqual([t.tolist() for t in new_dataloader]   ,[[8, 9, 1_0, 1_1], [1_2, 1_3, 1_4, 1_5]]     )






  def    SCREAMING_SNAKE_CASE ( self  :	Tuple     ):
   __lowercase				    =					DataLoaderShard(list(range(1_6     )     )   ,batch_size=4     )
   for idx, _ in enumerate(lowercase__     ):
    self.assertEqual(dataloader.end_of_dataloader   ,idx == 3     )

   # Test it also works on the second iteration
   for idx, _ in enumerate(lowercase__     ):
    self.assertEqual(dataloader.end_of_dataloader   ,idx == 3     )






  def    SCREAMING_SNAKE_CASE ( self  :	str     ):
   Accelerator()
   __lowercase				    =					DataLoaderDispatcher(range(1_6     )   ,batch_size=4     )
   for idx, _ in enumerate(lowercase__     ):
    self.assertEqual(dataloader.end_of_dataloader   ,idx == 3     )

   # Test it also works on the second iteration
   for idx, _ in enumerate(lowercase__     ):
    self.assertEqual(dataloader.end_of_dataloader   ,idx == 3     )





from __future__ import annotations

import math
def 	_UpperCamelCase					(    lowerCAmelCase_ )    ->bool:

   if 1 < number < 4:
      # 2 and 3 are primes
      return True
   elif number < 2 or number % 2 == 0 or number % 3 == 0:
      # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
      return False

   # All primes number are in format of 6k +/- 1
   for i in range(5	,    int(math.sqrt(lowerCAmelCase_ ) + 1 )	,    6 ):
      if number % i == 0 or number % (i + 2) == 0:
         return False
   return True


__a	 =      [num for num in range(3, 10_0001, 2) if not is_prime(num)]
def 	_UpperCamelCase					(    lowerCAmelCase_ )    ->list[int]:
   if not isinstance(lowerCAmelCase_	,    lowerCAmelCase_ ):
      raise ValueError("""n must be an integer""" )
   if n <= 0:
      raise ValueError("""n must be >= 0""" )

   UpperCAmelCase      					=  []
   for num in range(len(lowerCAmelCase_ ) ):
      UpperCAmelCase      					=  0
      while 2 * i * i <= odd_composites[num]:
         UpperCAmelCase      					=  odd_composites[num] - 2 * i * i
         if is_prime(lowerCAmelCase_ ):
            break
         i += 1
      else:
         list_nums.append(odd_composites[num] )
         if len(lowerCAmelCase_ ) == n:
            return list_nums

   return []
def 	_UpperCamelCase					(    )    ->int:
   return compute_nums(1 )[0]


if __name__ == "__main__":
 print(F"""{solution() = }""")



