def minibatch_fn(net, loss_fn, optimizer, batch):
    """
    Trains network for a single batch.

    Args:
      net (torch network)
          ANN network (nn.Module)

      loss_fn (torch loss)
          loss function for SGD

      optimizer (torch optimizer)
          optimizer for SGD

      batch (torch.Tensor)
          vectorized input images
             
    Returns:
      Nothing.
    """

    output_train = net(batch)
    loss = loss_fn(output_train, batch)

    optimizer.zero_grad()
    loss.backward()
    optimizer.step()

    return(loss)