parameters: (self, var_list=None)
docstring: Maintains moving averages of variables.
  
      `var_list` must be a list of `Variable` or `Tensor` objects.  This method
      creates shadow variables for all elements of `var_list`.  Shadow variables
      for `Variable` objects are initialized to the variable's initial value.
      They will be added to the `GraphKeys.MOVING_AVERAGE_VARIABLES` collection.
      For `Tensor` objects, the shadow variables are initialized to 0.
  
      shadow variables are created with `trainable=False` and added to the
      `GraphKeys.ALL_VARIABLES` collection.  They will be returned by calls to
      `tf.all_variables()`.
  
      Returns an op that updates all shadow variables as described above.
  
      Note that `apply()` can be called multiple times with different lists of
      variables.
  
      Args:
        var_list: A list of Variable or Tensor objects. The variables
          and Tensors must be of types float16, float32, or float64.
  
      Returns:
        An Operation that updates the moving averages.
  
      Raises:
        TypeError: If the arguments are not all float16, float32, or float64.
        ValueError: If the moving average of one of the variables is already
          being computed.
docstring_summary: Maintains moving averages of variables.
docstring_tokens: Maintains moving averages of variables .
function: def apply(self, var_list=None):
      """Maintains moving averages of variables.
  
      `var_list` must be a list of `Variable` or `Tensor` objects.  This method
      creates shadow variables for all elements of `var_list`.  Shadow variables
      for `Variable` objects are initialized to the variable's initial value.
      They will be added to the `GraphKeys.MOVING_AVERAGE_VARIABLES` collection.
      For `Tensor` objects, the shadow variables are initialized to 0.
  
      shadow variables are created with `trainable=False` and added to the
      `GraphKeys.ALL_VARIABLES` collection.  They will be returned by calls to
      `tf.all_variables()`.
  
      Returns an op that updates all shadow variables as described above.
  
      Note that `apply()` can be called multiple times with different lists of
      variables.
  
      Args:
        var_list: A list of Variable or Tensor objects. The variables
          and Tensors must be of types float16, float32, or float64.
  
      Returns:
        An Operation that updates the moving averages.
  
      Raises:
        TypeError: If the arguments are not all float16, float32, or float64.
        ValueError: If the moving average of one of the variables is already
          being computed.
      """
      # TODO(touts): op_scope
      if var_list is None:
        var_list = variables.trainable_variables()
      for var in var_list:
        if var.dtype.base_dtype not in [dtypes.float16, dtypes.float32,
                                        dtypes.float64]:
          raise TypeError("The variables must be half, float, or double: %s" %
                          var.name)
        if var in self._averages:
          raise ValueError("Moving average already computed for: %s" % var.name)
  
        # For variables: to lower communication bandwidth across devices we keep
        # the moving averages on the same device as the variables. For other
        # tensors, we rely on the existing device allocation mechanism.
        with ops.control_dependencies(None):
          if isinstance(var, variables.Variable):
            avg = slot_creator.create_slot(var,
                                           var.initialized_value(),
                                           self._name,
                                           colocate_with_primary=True)
            # NOTE(mrry): We only add `tf.Variable` objects to the
            # `MOVING_AVERAGE_VARIABLES` collection.
            ops.add_to_collection(ops.GraphKeys.MOVING_AVERAGE_VARIABLES, var)
          else:
            avg = slot_creator.create_zeros_slot(
                var,
                self._name,
                colocate_with_primary=(var.op.type == "Variable"))
        self._averages[var] = avg
  
      with ops.name_scope(self._name) as scope:
        decay = ops.convert_to_tensor(self._decay, name="decay")
        if self._num_updates is not None:
          num_updates = math_ops.cast(self._num_updates,
                                      dtypes.float32,
                                      name="num_updates")
          decay = math_ops.minimum(decay,
                                   (1.0 + num_updates) / (10.0 + num_updates))
        updates = []
        for var in var_list:
          updates.append(assign_moving_average(self._averages[var], var, decay))
        return control_flow_ops.group(*updates, name=scope)
function_tokens: def apply ( self , var_list = None ) : # TODO(touts): op_scope if var_list is None : var_list = variables . trainable_variables ( ) for var in var_list : if var . dtype . base_dtype not in [ dtypes . float16 , dtypes . float32 , dtypes . float64 ] : raise TypeError ( "The variables must be half, float, or double: %s" % var . name ) if var in self . _averages : raise ValueError ( "Moving average already computed for: %s" % var . name ) # For variables: to lower communication bandwidth across devices we keep # the moving averages on the same device as the variables. For other # tensors, we rely on the existing device allocation mechanism. with ops . control_dependencies ( None ) : if isinstance ( var , variables . Variable ) : avg = slot_creator . create_slot ( var , var . initialized_value ( ) , self . _name , colocate_with_primary = True ) # NOTE(mrry): We only add `tf.Variable` objects to the # `MOVING_AVERAGE_VARIABLES` collection. ops . add_to_collection ( ops . GraphKeys . MOVING_AVERAGE_VARIABLES , var ) else : avg = slot_creator . create_zeros_slot ( var , self . _name , colocate_with_primary = ( var . op . type == "Variable" ) ) self . _averages [ var ] = avg with ops . name_scope ( self . _name ) as scope : decay = ops . convert_to_tensor ( self . _decay , name = "decay" ) if self . _num_updates is not None : num_updates = math_ops . cast ( self . _num_updates , dtypes . float32 , name = "num_updates" ) decay = math_ops . minimum ( decay , ( 1.0 + num_updates ) / ( 10.0 + num_updates ) ) updates = [ ] for var in var_list : updates . append ( assign_moving_average ( self . _averages [ var ] , var , decay ) ) return control_flow_ops . group ( * updates , name = scope )