def METHOD_NAME(img: Union[Tensor, Image.Image]) -> np.ndarray:
    out: np.ndarray
    if isinstance(img, np.ndarray):
        out = img
    elif isinstance(img, Image.Image):
        out = np.array(img)
    elif isinstance(img, Tensor):
        out = img.squeeze(0).permute(1, 2, 0).cpu().numpy()
    else:
        raise TypeError(f"Unknown image type. Got: {type(img)}.")
    return out