from typing import Tuple
from typing import List
from typing import Union


def block_coords_to_slice_or_int_tuple(
    block_coords: Tuple[int, ...], block_sizes: List[int],
    dimensions: List[int]) -> Tuple[Union[int, slice], ...]:
  """Returns the tuple of slices corresponding to the coordinates for a block."""
  slice_or_int_list = []
  for block_coord, block_size, dimension in zip(block_coords, block_sizes,
                                                dimensions):
    start = block_coord * block_size
    stop = (block_coord + 1) * block_size
    stop = min(dimension, stop)  # Prevent indexing beyond dimension limit.
    slice_or_int_list.append(slice(start, stop))
  return tuple(slice_or_int_list)