parameters: (self)
return_statement: return bprop
docstring: Grad definition for `LSTM` operation.
docstring_summary: Grad definition for `LSTM` operation.
docstring_tokens: Grad definition for LSTM operation .
function: def get_bprop_lstm(self):
      """Grad definition for `LSTM` operation."""
      lstm_grad_data = G.LSTMGradData(
          input_size=self.input_size,
          hidden_size=self.hidden_size,
          num_layers=self.num_layers,
          has_bias=self.has_bias,
          bidirectional=self.bidirectional,
          dropout=self.dropout
      )
  
      lstm_grad_weight = G.LSTMGradWeight(
          input_size=self.input_size,
          hidden_size=self.hidden_size,
          num_layers=self.num_layers,
          has_bias=self.has_bias,
          bidirectional=self.bidirectional,
          dropout=self.dropout
      )
      lstm_grad = G.LSTMGrad(
          input_size=self.input_size,
          hidden_size=self.hidden_size,
          num_layers=self.num_layers,
          has_bias=self.has_bias,
          bidirectional=self.bidirectional,
          dropout=self.dropout
      )
  
      def bprop(x, hx, cx, w, out, dout):
          y, _, _, reserve, state = out
          dy, dhy, dcy, _, _ = dout
          dx, dhx, dcx = lstm_grad_data(y, dy, dhy, dcy, w, hx, cx, reserve, state)
          dw = lstm_grad_weight(F.depend(x, dx), hx, y, reserve, state)
          return dx, dhx, dcx, dw
  
      #
      def bprop_cpu(x, hx, cx, w, out, dout):
          y, hy, cy, reserve, _ = out
          dy, dhy, dcy, _, _ = dout
          dx, dhx, dcx, dw = lstm_grad(x, hx, cx, w, y, hy, cy, dy, dhy, dcy, reserve)
          return dx, dhx, dcx, dw
  
      if context.get_context('device_target') == "CPU":
          return bprop_cpu
  
      return bprop
function_tokens: def get_bprop_lstm ( self ) : lstm_grad_data = G . LSTMGradData ( input_size = self . input_size , hidden_size = self . hidden_size , num_layers = self . num_layers , has_bias = self . has_bias , bidirectional = self . bidirectional , dropout = self . dropout ) lstm_grad_weight = G . LSTMGradWeight ( input_size = self . input_size , hidden_size = self . hidden_size , num_layers = self . num_layers , has_bias = self . has_bias , bidirectional = self . bidirectional , dropout = self . dropout ) lstm_grad = G . LSTMGrad ( input_size = self . input_size , hidden_size = self . hidden_size , num_layers = self . num_layers , has_bias = self . has_bias , bidirectional = self . bidirectional , dropout = self . dropout ) def bprop ( x , hx , cx , w , out , dout ) : y , _ , _ , reserve , state = out dy , dhy , dcy , _ , _ = dout dx , dhx , dcx = lstm_grad_data ( y , dy , dhy , dcy , w , hx , cx , reserve , state ) dw = lstm_grad_weight ( F . depend ( x , dx ) , hx , y , reserve , state ) return dx , dhx , dcx , dw # def bprop_cpu ( x , hx , cx , w , out , dout ) : y , hy , cy , reserve , _ = out dy , dhy , dcy , _ , _ = dout dx , dhx , dcx , dw = lstm_grad ( x , hx , cx , w , y , hy , cy , dy , dhy , dcy , reserve ) return dx , dhx , dcx , dw if context . get_context ( 'device_target' ) == "CPU" : return bprop_cpu return bprop