TD-lambda returns.
1676
def lambda_return(reward, value, length, discount, lambda_):
  """"""
  timestep = tf.range(reward.shape[1].value)
  mask = tf.cast(timestep[None, :] < length[:, None], tf.float32)
  sequence = mask * reward + discount * value * (1 - lambda_)
  discount = mask * discount * lambda_
  sequence = tf.stack([sequence, discount], 2)
  return_ = tf.reverse(tf.transpose(tf.scan(
      lambda agg, cur: cur[0] + cur[1] * agg,
      tf.transpose(tf.reverse(sequence, [1]), [1, 2, 0]),
      tf.zeros_like(value[:, -1]), 1, False), [1, 0]), [1])
  return tf.check_numerics(tf.stop_gradient(return_), 'return')
1127475
def method(func):
    """"""
    attr = abc.abstractmethod(func)
    attr.__imethod__ = True
    return attr
1329210
def _get_populate_from_value(self, instance):
        """"""
        if hasattr(self.populate_from, '__call__'):
            # ResolweSlugField(populate_from=lambda instance: ...)
            return self.populate_from(instance)
        else:
            # ResolweSlugField(populate_from='foo')
            attr = getattr(instance, self.populate_from)
            return attr() if callable(attr) else attr
449322
function (cell) {
            try {
                var start = domUtils.getXY(cell).x + cell.offsetWidth,
                    rows = this.table.rows, cells , returns = [];
                for (var i = 0; i < this.rowsNum; i++) {
                    cells = rows[i].cells;
                    for (var j = 0, tmpCell; tmpCell = cells[j++];) {
                        var tmpStart = domUtils.getXY(tmpCell).x;
                        if (tmpStart > start) break;
                        if (tmpStart == start && tmpCell.colSpan == 1) {
                            returns.push(tmpCell);
                            break;
                        }
                    }
                }
                return returns;
            } catch (e) {
                showError(e);
            }
        }
299592
function (d) {
                    if (d != null) {
                        if (_iss(d)) {
                            return getValue(d);
                        }
                        else if (_isf(d) && (functionPrefix == null || (d.name || "").indexOf(functionPrefix) === 0)) {
                            return d(values);
                        }
                        else if (_isa(d)) {
                            var r = [];
                            for (var i = 0; i < d.length; i++)
                                r.push(_one(d[i]));
                            return r;
                        }
                        else if (_iso(d)) {
                            var s = {};
                            for (var j in d) {
                                s[j] = _one(d[j]);
                            }
                            return s;
                        }
                        else {
                            return d;
                        }
                    }
                }
91281
def getCol(self, x):
        """"""
        return [self.getCell(x, i) for i in self.__size_range]
172735
function method (lambda) {
  return function () {
    return lambda.apply(null, [this].concat(Array.prototype.slice.call(arguments, 0)));
  };
}
15479
function(syntax, name, minScore) {
			var result = this.fuzzyFindMatches(syntax, name, minScore)[0];
			if (result) {
				return result.value.parsedValue;
			}
		}
1155544
function(event, data) {
				var i,
					node = data.node,
					$tdList = $(node.tr).find(">td"),
					cnList = node.data.vernacularNames
						? $.map(node.data.vernacularNames, function(o) {
								return o.vernacularName;
						  })
						: [];

				i = 0;
				function _setCell($cell, text) {
					$("<div class='truncate'>")
						.attr("title", text)
						.text(text)
						.appendTo($cell);
				}
				$tdList.eq(i++).text(node.key);
				$tdList.eq(i++).text(node.data.rank);
				i++; // #1: node.title = scientificName
				// $tdList.eq(i++).text(cnList.join(", "));
				_setCell($tdList.eq(i++), cnList.join(", "));
				$tdList.eq(i++).text(node.data.canonicalName);
				// $tdList.eq(i++).text(node.data.accordingTo);
				_setCell($tdList.eq(i++), node.data.accordingTo);
				$tdList.eq(i++).text(node.data.taxonomicStatus);
				$tdList.eq(i++).text(node.data.nameType);
				$tdList.eq(i++).text(node.data.numOccurrences);
				$tdList.eq(i++).text(node.data.numDescendants);
				// $tdList.eq(i++).text(node.data.authorship);
				_setCell($tdList.eq(i++), node.data.authorship);
				// $tdList.eq(i++).text(node.data.publishedIn);
				_setCell($tdList.eq(i++), node.data.publishedIn);
			}
607948
def returned(self):
        """"""
        if self._returned is None:
            node = _parse_text(self.extracted)
            self._returned = usefunction._returns_last(node)
        return self._returned
1207864
def find_column(t):
    """"""
    pos = t.lexer.lexpos
    data = t.lexer.lexdata
    last_cr = data.rfind('\n', 0, pos)
    if last_cr < 0:
        last_cr = -1
    column = pos - last_cr
    return column
1348109
function getColIdx($tr, $td) {
		var colspan,
			td = $td.get(0),
			idx = 0;

		$tr.children().each(function() {
			if (this === td) {
				return false;
			}
			colspan = $(this).prop("colspan");
			idx += colspan ? colspan : 1;
		});
		return idx;
	}
55485
function (node) {
    const parent = node.parentNode
    return parent.classList.contains('code') && parent.nodeName === 'TD' && node.nodeName === 'PRE'
  }
286959
def stmt_lambda_name(self, index=None):
        """"""
        if index is None:
            index = len(self.stmt_lambdas)
        return stmt_lambda_var + "_" + str(index)
301685
function(table) {
    var rows = 0;
    var columns = 0;
    var trs = table.getElementsByTagName("tr");
    for (var i = 0; i < trs.length; i++) {
      var rowspan = trs[i].getAttribute("rowspan") || 0;
      if (rowspan) {
        rowspan = parseInt(rowspan, 10);
      }
      rows += (rowspan || 1);

      // Now look for column-related info
      var columnsInThisRow = 0;
      var cells = trs[i].getElementsByTagName("td");
      for (var j = 0; j < cells.length; j++) {
        var colspan = cells[j].getAttribute("colspan") || 0;
        if (colspan) {
          colspan = parseInt(colspan, 10);
        }
        columnsInThisRow += (colspan || 1);
      }
      columns = Math.max(columns, columnsInThisRow);
    }
    return {rows: rows, columns: columns};
  }
1050447
def _produce_return(self, cursor):
        
        results = cursor.fetchmany(2)
        if len(results) != 1:
            return None

        # Return the one row, or the one column.
        row = results[0]
        if self._row_formatter is not None:
            row = self._row_formatter(row, cursor)
        elif len(row) == 1:
            row = row[0]

        return row
1230545
def _expr2code(self, arg_list, expr):
        """"""
        code = lambdastr(arg_list, expr)
        function_code = code.split(':')[1].strip()
        #for arg in arg_list:
        #    function_code = function_code.replace(arg.name, 'self.'+arg.name)

        return function_code