def get_anchor_step(run, anchor, step, slice):
    """
    Helper function to get a specific tensor's batch result from a Run object.

    run    - the Run object to take the tensor from.
    anchor - the tensor name of the anchors to return values for.
    step   - the batch number to return values for.
    slice  - gives you an ability to slice the value in the first axis if a
             tensor is, say, a number of stacked dropout results from a loop.
             The slice is defined by a tuple comprising
             (<index of slice>/<number of slices>) and assumes it always slices
             in the first axis and in equal parts.
    """
    out = run.anchors[run.random_outs[anchor]]
    if run.steps > 1:
        out = out[step]

    # Take a slice of the tensor.
    slice_size = out.shape[0] // slice.total_slices
    out = out[slice.index * slice_size:(slice.index + 1) * slice_size]
    return out