class_docstr: This class is for parsing lines like
  stats-layer name=tdnn1-stats config=mean+stddev(-99:3:9:99) input=tdnn1
  
  This adds statistics-pooling and statistics-extraction components.  An
  example string is 'mean(-99:3:9::99)', which means, compute the mean of
  data within a window of -99 to +99, with distinct means computed every 9
  frames (we round to get the appropriate one), and with the input extracted
  on multiples of 3 frames (so this will force the input to this layer to be
  evaluated every 3 frames).  Another example string is
  'mean+stddev(-99:3:9:99)', which will also cause the standard deviation to
  be computed.
  
  The dimension is worked out from the input. mean and stddev add a
  dimension of input_dim each to the output dimension. If counts is
  specified, an additional dimension is added to the output to store log
  counts.
  
  Parameters of the class, and their defaults:
      input='[-1]'    [Descriptor giving the input of the layer.]
      dim=-1      [Output dimension of layer. If provided, must match the
                   dimension computed from input]
      config=''   [Required. Defines what stats must be computed.]
class_docstr_tok: ["This","class","is","for","parsing","lines","like","stats-layer","name=tdnn1-stats","config=mean+stddev","(","-99:3:9:99",")","input=tdnn1","This","adds","statistics-pooling","and","statistics-extraction","components",".","An","example","string","is","'mean","(","-99:3:9",":",":99",")","'",",","which","means",",","compute","the","mean","of","data","within","a","window","of","-99","to","+99",",","with","distinct","means","computed","every","9","frames","(","we","round","to","get","the","appropriate","one",")",",","and","with","the","input","extracted","on","multiples","of","3","frames","(","so","this","will","force","the","input","to","this","layer","to","be","evaluated","every","3","frames",")",".","Another","example","string","is","'mean+stddev","(","-99:3:9:99",")","'",",","which","will","also","cause","the","standard","deviation","to","be","computed",".","The","dimension","is","worked","out","from","the","input",".","mean","and","stddev","add","a","dimension","of","input_dim","each","to","the","output","dimension",".","If","counts","is","specified",",","an","additional","dimension","is","added","to","the","output","to","store","log","counts",".","Parameters","of","the","class",",","and","their","defaults",":","input=","'","[","-1","]","'","[","Descriptor","giving","the","input","of","the","layer",".","]","dim=-1","[","Output","dimension","of","layer",".","If","provided",",","must","match","the","dimension","computed","from","input","]","config=","''","[","Required",".","Defines","what","stats","must","be","computed",".","]"]
code: def set_derived_configs(self):
      config_string = self.config["config"]
      if config_string == "":
          raise RuntimeError("config has to be non-empty", self.str())
      m = re.search(
          "(mean|mean\+stddev|mean\+count|mean\+stddev\+count)"
          "\((-?\d+):(-?\d+):(-?\d+):(-?\d+)\)",
          config_string,
      )
      if m is None:
          raise RuntimeError(
              "Invalid statistic-config string: {0}".format(
                  config_string
              ),
              self,
          )
  
      self._output_stddev = m.group(1) in [
          "mean+stddev",
          "mean+stddev+count",
      ]
      self._output_log_counts = m.group(1) in [
          "mean+count",
          "mean+stddev+count",
      ]
      self._left_context = -int(m.group(2))
      self._input_period = int(m.group(3))
      self._stats_period = int(m.group(4))
      self._right_context = int(m.group(5))
  
      if self._output_stddev:
          output_dim = 2 * self.descriptors["input"]["dim"]
      else:
          output_dim = self.descriptors["input"]["dim"]
      if self._output_log_counts:
          output_dim = output_dim + 1
  
      if self.config["dim"] > 0 and self.config["dim"] != output_dim:
          raise RuntimeError(
              "Invalid dim supplied {0:d} != "
              "actual output dim {1:d}".format(
                  self.config["dim"], output_dim
              )
          )
      self.config["dim"] = output_dim
  
file_path: espnet/egs2/mucs21_subtask1/asr1/steps/libs/nnet3/xconfig/stats_layer.py
imports: from __future__ import print_function
  import re
  from libs.nnet3.xconfig.basic_layers import XconfigLayerBase
label_desc: Use image node_id 3 for calling the XconfigStatsLayer obj's underlying member method code with example usage: obj.set_derived_configs() without return types