def METHOD_NAME(
    tiles: np.ndarray,
    tile_shape: Tuple[int, ...],
    sample_shape: Optional[Tuple[int, ...]],
    dtype: Optional[Union[str, np.dtype]] = None,
) -> np.ndarray:
    """Coalesce tiles into a single array of shape `sample_shape`.
    Args:
        tiles (np.ndarray): numpy object array of tiles.
        tile_shape (Tuple[int, ...]): Tile shape. Corner tiles may be smaller than this.
        sample_shape (Optional, Tuple[int, ...]): Shape of the output array. The sum of all actual tile shapes are expected to be equal to this.
        dtype (Optional, Union[str, np.dtype]): Dtype of the output array. Should match dtype of tiles.
    Raises:
        TypeError: If `tiles` is not deserialized.
    Returns:
        np.ndarray: Sample array from tiles.
    """
    if dtype is None:
        dtype = next(iter(tiles.flat)).dtype
    ndim = tiles.ndim
    sample_shape = sample_shape or tuple(  # Infer sample shape from tile shapes
        sum(
            tile.shape[i]
            for tile in tiles[tuple(slice(None) if j == i else 0 for j in range(ndim))]  # type: ignore
        )
        for i in range(ndim)
    )
    sample = np.empty(sample_shape, dtype=dtype)
    if tiles.size <= 0:
        return sample
    for tile_coords, tile in np.ndenumerate(tiles):
        low = np.multiply(tile_coords, tile_shape)
        high = low + tile.shape
        idx = tuple(slice(l, h) for l, h in zip(low, high))
        view = sample[idx]
        view[:] = tile
    return sample