class_docstr: Maintains the moving average (i.e., the average of the latest N records)
  of a single metric.
  
  Args:
      size (int, optional): The window size of moving average. If `None`,
          the average of all added records is maintained.
      name (str, optional): name of the recorder. Used when printing.
class_docstr_tok: ["Maintains","the","moving","average","(","i.e.",",","the","average","of","the","latest","N","records",")","of","a","single","metric",".","Args",":","size","(","int",",","optional",")",":","The","window","size","of","moving","average",".","If","`","None","`",",","the","average","of","all","added","records","is","maintained",".","name","(","str",",","optional",")",":","name","of","the","recorder",".","Used","when","printing","."]
docstr: Returns a string of the average value.
  
  Args:
      precision (int, optional): The number of decimal places to keep in
          the returned string. E.g., for an average value of `0.1234`,
          :attr:`precision = 2` leads to `'0.12'`.
  
  Returns:
      A string of the average value. If :meth:`name` is given, the
      string is of the format like `'name: 0.1234'`, otherwise
      the string is of the format like `'0.1234'`.
docstr_tok: ["Returns","a","string","of","the","average","value",".","Args",":","precision","(","int",",","optional",")",":","The","number","of","decimal","places","to","keep","in","the","returned","string",".","E.g.",",","for","an","average","value","of","`","0.1234","`",",",":","attr",":","`","precision","=","2","`","leads","to","`","'","0.12","'","`",".","Returns",":","A","string","of","the","average","value",".","If",":","meth",":","`","name","`","is","given",",","the","string","is","of","the","format","like","`","'name",":","0.1234","'","`",",","otherwise","the","string","is","of","the","format","like","`","'","0.1234","'","`","."]
code: def to_str(self, precision=None):
      """Returns a string of the average value.
  
      Args:
          precision (int, optional): The number of decimal places to keep in
              the returned string. E.g., for an average value of `0.1234`,
              :attr:`precision = 2` leads to `'0.12'`.
  
      Returns:
          A string of the average value. If :meth:`name` is given, the
          string is of the format like `'name: 0.1234'`, otherwise
          the string is of the format like `'0.1234'`.
      """
      prec_str = "{}"
      if precision is not None:
          prec_str = "{:.%df}" % precision
  
      avg_str = prec_str.format(self.avg())
      if self._name is not None:
          avg_str = "{}: {}".format(self._name, avg_str)
  
      return avg_str
  
file_path: texar/texar/tf/utils/average_recorder.py
imports: from collections import deque
label_desc: Use image node_id 5 for calling the _SingleAverageRecorder obj's underlying member method code with example usage: obj.to_str(precision) and returns: avg_str