def add_single_bd(x: np.ndarray, distance: int = 2, pixel_value: int = 1) -> np.ndarray:
    """
    Augments a matrix by setting value some `distance` away from the bottom-right edge to 1. Works for a single image
    or a batch of images.

    :param x: A single image or batch of images of shape NWHC, NHW, or HC. Pixels will be added to all channels.
    :param distance: Distance from bottom-right walls.
    :param pixel_value: Value used to replace the entries of the image matrix.
    :return: Backdoored image.
    """
    x = np.copy(x)
    shape = x.shape
    if len(shape) == 4:
        height, width = x.shape[1:3]
        x[:, height - distance, width - distance, :] = pixel_value
    elif len(shape) == 3:
        height, width = x.shape[1:]
        x[:, height - distance, width - distance] = pixel_value
    elif len(shape) == 2:
        height, width = x.shape
        x[height - distance, width - distance] = pixel_value
    else:
        raise ValueError(f"Invalid array shape: {shape}")
    return x

    Augments a matrix by setting value some `distance` away from the bottom-right edge to 1. Works for a single image
    or a batch of images.

    :param x: A single image or batch of images of shape NWHC, NHW, or HC. Pixels will be added to all channels.
    :param distance: Distance from bottom-right walls.
    :param pixel_value: Value used to replace the entries of the image matrix.
    :return: Backdoored image.
    
art/attacks/poisoning/perturbations/image_perturbations.py