code: def apply_momentum(updates, params=None, momentum=0.9):
      """Returns a modified update dictionary including momentum
  
      Generates update expressions of the form:
  
      * ``velocity := momentum * velocity + updates[param] - param``
      * ``param := param + velocity``
  
      Parameters
      ----------
      updates : OrderedDict
          A dictionary mapping parameters to update expressions
      params : iterable of shared variables, optional
          The variables to apply momentum to. If omitted, will apply
          momentum to all `updates.keys()`.
      momentum : float or symbolic scalar, optional
          The amount of momentum to apply. Higher momentum results in
          smoothing over more update steps. Defaults to 0.9.
  
      Returns
      -------
      OrderedDict
          A copy of `updates` with momentum updates for all `params`.
  
      Notes
      -----
      Higher momentum also results in larger update steps. To counter that,
      you can optionally scale your learning rate by `1 - momentum`.
  
      See Also
      --------
      momentum : Shortcut applying momentum to SGD updates
      """
      if params is None:
          params = updates.keys()
      updates = OrderedDict(updates)
  
      for param in params:
          value = param.get_value(borrow=True)
          velocity = theano.shared(
              np.zeros(value.shape, dtype=value.dtype),
              broadcastable=param.broadcastable,
          )
          x = momentum * velocity + updates[param]
          updates[velocity] = x - param
          updates[param] = x
  
      return updates
  
file_path: Lasagne/lasagne/updates.py
imports: from collections import OrderedDict
  import numpy
  import theano
  import theano.tensor
  from .None import utils
label_desc: Use image node_id 3 for calling a global function with example usage: apply_momentum(updates, params, momentum) and returns: updates