class_docstr: .. math::
  
      L = \beta \| h_t-h_{t+1} \|_2^2,
  
  where :math:`h_t` is the output of the RNN at timestep t,
  :math:`h_{t+1}` is the output of the RNN at timestep t+1, :math:`\beta`
  is scaling coefficient.
  
  The implementation follows [MMS17]_.
  Computes Temporal Activation Regularization Loss. (alias: TAR)
  
  Parameters
  ----------
  beta
      The scaling coefficient of the regularization.
  weight
      Global scalar weight for loss.
  batch_axis
      The axis that represents mini-batch.
  time_axis
      The axis that represents time-step.
class_docstr_tok: ["..","math",":",":","L","=","\\beta","\\|","h_t-h_","{","t+1","}","\\|_2^2",",","where",":","math",":","`","h_t","`","is","the","output","of","the","RNN","at","timestep","t",",",":","math",":","`","h_","{","t+1","}","`","is","the","output","of","the","RNN","at","timestep","t+1",",",":","math",":","`","\\beta","`","is","scaling","coefficient",".","The","implementation","follows","[","MMS17","]","_.","Computes","Temporal","Activation","Regularization","Loss",".","(","alias",":","TAR",")","Parameters","--","--","--","--","--","beta","The","scaling","coefficient","of","the","regularization",".","weight","Global","scalar","weight","for","loss",".","batch_axis","The","axis","that","represents","mini-batch",".","time_axis","The","axis","that","represents","time-step","."]
docstr: Parameters
  ----------
  states
      the stack outputs from RNN, which consists of output from each time
      step.
  
  Returns
  --------
  Tensor
      loss tensor with shape (batch_size,). Dimensions other than
      batch_axis are averaged out.
docstr_tok: ["Parameters","--","--","--","--","--","states","the","stack","outputs","from","RNN",",","which","consists","of","output","from","each","time","step",".","Returns","--","--","--","--","Tensor","loss","tensor","with","shape","(","batch_size",",",")",".","Dimensions","other","than","batch_axis","are","averaged","out","."]
code: def hybrid_forward(self, F, *states: List[Tensor]) -> Tensor:
      """
      Parameters
      ----------
      states
          the stack outputs from RNN, which consists of output from each time
          step.
  
      Returns
      --------
      Tensor
          loss tensor with shape (batch_size,). Dimensions other than
          batch_axis are averaged out.
      """
      if self._beta != 0 and states:
          means = []
          for state in states:
              if isinstance(state, list):
                  state = F.stack(*state, axis=self._time_axis)
              sub_state_1 = F.slice_axis(
                  state, axis=self._time_axis, begin=1, end=None
              )
              sub_state_2 = F.slice_axis(
                  state, axis=self._time_axis, begin=0, end=-1
              )
              sub_state_diff = F.elemwise_sub(sub_state_1, sub_state_2)
              means.append(
                  self._beta
                  * F.power(sub_state_diff, 2).mean(
                      axis=self._batch_axis, exclude=True
                  )
              )
          return F.add_n(*means)
      return F.zeros(1)
  
file_path: gluonts/src/gluonts/mx/block/regularization.py
imports: from typing import List, Optional
  from mxnet.gluon.loss import Loss
  from gluonts.core.component import validated
  from gluonts.mx import Tensor
label_desc: Use image node_id 3 for calling the TemporalActivationRegularizationLoss obj's underlying member method code with example usage: obj.hybrid_forward(F) and returns: F, F