from typing import List
from typing import Tuple


def _get_neighbors(x: int, y: int, dataset: List[List[float]]) -> List[Tuple[int, int]]:
    """Gets the neighbors of dataset[y][x] in a 3x3 kernel.

    Args:
        x (int): Row
        y (int): Column
        dataset (list of lists): A 2D list representing the dataset

    Returns:
        list of tuples: Each tuple contains indices of a particular neighbor
    """
    width = len(dataset[0])
    height = len(dataset)

    # These hacks ensure that we don't throw an index error.
    if x == width - 1:
        x = -1
    if y == height - 1:
        y = -1

    neighbors = []
    neighbors.extend(
        [
            dataset[y - 1][x - 1],
            dataset[y - 1][x],
            dataset[y - 1][x + 1],
            dataset[y][x - 1],
            dataset[y][x + 1],
            dataset[y + 1][x - 1],
            dataset[y + 1][x],
            dataset[y + 1][x + 1],
        ]
    )

    return neighbors