
    0Rj                         d Z ddlZddlZddlmZ ddgiZg dZdedd	Zd
deddZ	ddefdZ
defdZdefdZdefdZy)z#
Thin wrappers around `itertools`.
    N   )tqdmzgithub.com/	casperdcl)chainproductpermutationscombinationscombinations_with_replacementbatched)total
tqdm_classc                     | 	 t        t        t        |            }  |t        j                  | fd| i|S # t        t        f$ r Y ,w xY w)z Equivalent of `itertools.chain`.r   )summaplen	TypeErrorAttributeError	itertoolsr   )r   r   	iterableskwargss       ^/var/www/html/meridian/meridian-ai/venv/lib/python3.12/site-packages/tqdm/contrib/itertools.pyr   r      sV    }	C+,E iooy1II&II >* 		s   8 A
	A
   )repeatr   r   c              /      K   |2	 t        t        t        |            }t        j                  |      | z  } |t        j                  |d| ifd|i|E d{    y# t
        t        f$ r Y 8w xY w7 w)z"Equivalent of `itertools.product`.Nr   r   )	listr   r   mathprodr   r   r   r   )r   r   r   r   r   lenss         r   r   r      s}     }	.C+,D IIdOv-E)++YFvF^e^W]^^^	 >* 		 _s3   A5A 9A5A3A5A0-A5/A00A5c                     |1	 t        |       }||n|}||kD  rd}nt        j                  ||      }	  |t        j                  | |      fd|i|S # t        t        f$ r Y 0w xY w)z'Equivalent of `itertools.permutations`.r   r   )r   r   permr   r   r   r   iterablerr   r   r   ns         r   r   r   $   sx    }		(HA YAA1u		!Qi,,Xq9QQ&QQ >* 		s   A A%$A%c                     |+	 t        |       }||kD  rd}nt        j                  ||      }	  |t        j                  | |      fd|i|S # t        t        f$ r Y 0w xY w)z'Equivalent of `itertools.combinations`.r   r   )r   r   combr   r   r   r	   r!   s         r   r	   r	   4   sm    }	(HA 1u		!Qi,,Xq9QQ&QQ >* 		s   A AAc                     |H	 t        |       }d}t        ||z   dz
  |dz
  d      D ]  }||z  }	 t        d|dz         D ]  }||z  }	 	  |t	        j
                  | |      fd|i|S # t        t        f$ r Y 0w xY w)z8Equivalent of `itertools.combinations_with_replacement`.r   r   )r   ranger   r   r   r
   )r"   r#   r   r   r   r$   is          r   r
   r
   C   s    }		HA E1Q3q5!A#r* 
1ac] !i==hJbRWb[abb >* 		s   A* *A<;A<c                     |	 t        |       } |t        j                  | |      f||||z   dz
  |z  ndd|S # t        t        f$ r Y >w xY w)z"Equivalent of `itertools.batched`.Nr   )
unit_scaler   )r   r   r   r   r   )r"   r$   r   r   r   s        r   r   r   S   sr    }	ME i''!4  050AU1WQY1,t     >* 		s   < AA)__doc__r   r   autor   	tqdm_auto
__author____all__r   r   r   r	   r
   r        r   <module>r4      sz      $k]+
d !Y J  ! 	_ ") R  %)Y R 6:i c   $	 	 r3   