from typing import Iterable, Tuple, Any __all__ = ["module2dict", "iter_batch"] def module2dict(module) -> dict[str, Any]: result = {} for key, value in vars(module).items(): if key.isupper(): result[key] = value return result def iter_batch(batch_size: int, batch_index: int, ) -> Iterable[Tuple[int, int]]: for index, part_index in enumerate(range(batch_index * batch_size, (batch_index + 1) * batch_size)): yield index, part_index