def metric_batch(model, metric_func, xb, yb):
    """Compute metric of model on a batch data.

    metric_batch provide a way to compute model metric with mini-batch data.
    The metric can be accuracy. It is necessary that metric_batch should be
    implemented under torch.no_grad().

    Args:
        model (Model): a model with weights which can be updated
        metric_func (function): a function used to compute metric
        xb (tensor): features of a mini-batch data
        yb (tensor): labels of a mini-batch data corresponding to xb

    Example::

        >>> import torch
        >>> x = torch.tensor([[1, 2, 3], [3, 4, 5]])
        >>> y = torch.tensor([0, 1])
        >>> def accuracy(out, y):
        >>>     preds = torch.argmax(out, dim=1)
        >>>     return (preds == y).float().mean()
        >>> model = Mnist_CNN()
        >>> with torch.no_grad():
        >>>     acc = metric_batch(model, accuracy, x, y)

    Returns:
        (float): a metric of model w.r.t the pair of xb and yb

    """
    metric = metric_func(model(xb), yb)
    return metric.item()