def cross_entropy_multi(backend, outputs, targets, temp, epsilon=2**-23,
                        scale_by_batchsize=False):
    """
    Evaluates cross entropy on elements from outputs and targets.

    Arguments:
        backend (Backend): The backend class to use for computation.
        outputs (Tensor): predicted output values to be compared.
        targets (Tensor): known outcome values to be compared against.
        temp (Tensor): temporary buffers.
        epsilon (numeric): unit roundoff error.  Defaults to 2^-23, which
                           matches python float32 machine epsilon.

    Returns:
        Tensor: Calculated cross entropy values for each element.
    """

    # Compute (t*log(y)).
    backend.add(outputs, epsilon, out=temp[1])
    backend.log(temp[1], out=temp[1])
    backend.multiply(targets, temp[1], out=temp[1])
    backend.multiply(temp[1], -1.0, out=temp[0])
    result = backend.empty((1, 1), dtype=outputs.dtype)
    if scale_by_batchsize:
        backend.divide(temp[0], temp[0].shape[1], temp[0])
    return backend.sum(temp[0], axes=None, out=result)