'For all pairs (term, input) such that `input` is an input to `term`,
compute a mapping::
(term, input) -> offset(term, input)
where ``offset(term, input)`` is the number of rows that ``term``
should truncate off the raw array produced for ``input`` before using
it. We compute this value as follows::
offset(term, input) = (extra_rows_computed(input)
- extra_rows_computed(term)
- requested_extra_rows(term, input))
Examples
Case 1
Factor A needs 5 extra rows of USEquityPricing.close, and Factor B
needs 3 extra rows of the same.  Factor A also requires 5 extra rows of
USEquityPricing.high, which no other Factor uses.  We don\'t require any
extra rows of Factor A or Factor B
We load 5 extra rows of both `price` and `high` to ensure we can
service Factor A, and the following offsets get computed::
offset[Factor A, USEquityPricing.close] == (5 - 0) - 5 == 0
offset[Factor A, USEquityPricing.high]  == (5 - 0) - 5 == 0
offset[Factor B, USEquityPricing.close] == (5 - 0) - 3 == 2
offset[Factor B, USEquityPricing.high] raises KeyError.
Case 2
Factor A needs 5 extra rows of USEquityPricing.close, and Factor B
needs 3 extra rows of Factor A, and Factor B needs 2 extra rows of
USEquityPricing.close.
We load 8 extra rows of USEquityPricing.close (enough to load 5 extra
rows of Factor A), and the following offsets get computed::
offset[Factor A, USEquityPricing.close] == (8 - 3) - 5 == 0
offset[Factor B, USEquityPricing.close] == (8 - 0) - 2 == 6
offset[Factor B, Factor A]              == (3 - 0) - 3 == 0
Notes
`offset(term, input) >= 0` for all valid pairs, since `input` must be
an input to `term` if the pair appears in the mapping.
This value is useful because we load enough rows of each input to serve
all possible dependencies.  However, for any given dependency, we only
want to compute using the actual number of required extra rows for that
dependency.  We can do so by truncating off the first `offset` rows of
the loaded data for `input`.
See Also
zipline.pipeline.graph.TermGraph.offset
zipline.pipeline.engine.SimplePipelineEngine._inputs_for_term
zipline.pipeline.engine.SimplePipelineEngine._mask_and_dates_for_term'

@lazyval
def offset(self):

    extra = self.extra_rows
    return {(term, dep): ((extra[dep] - extra[term]) - requested_extra_rows) for term in self.graph for (dep, requested_extra_rows) in term.dependencies.items()}
