def format_batch_dim(shape: list) -> list:
    """
    Turn any None entry in a shape, which represents an unknown batch size, by a -1, which represents all
    remaining elements. Need to do this because None is not supported by tf.reshape.

    :param shape: A list representing a shape with potentially a None for the batch dimension.
    :return: A list with any None replaced by -1.
    """
    return [s if s is not None else -1 for s in shape]