anchor.diff:      let hs = Parameter <| dsharp.tensor([])
       do 
           base.add(layers |> Array.map box, Array.init numLayers (fun i -> sprintf "RNN-layer-%A" i))
  +        if bidirectional then base.add(layersReverse |> Array.map box, Array.init numLayers (fun i -> sprintf "RNN-layer-reverse-%A" i))
           if dropout > 0. then base.add([dropoutLayer], ["RNN-dropout"])
   
       member _.hidden
  
positive.code:             if bias then r.hidden <- r.hidden + b.value
              r.hidden <- nonlinearity r.hidden
              output.[i] <- r.hidden
          dsharp.stack output
  
  
  type RNN(inFeatures, outFeatures, ?nonlinearity, ?numLayers, ?bias, ?dropout, ?bidirectional) =
      inherit Model()
      let numLayers = defaultArg numLayers 1
      let dropout = defaultArg dropout 0.
      let bidirectional = defaultArg bidirectional false
      let numDirections = if bidirectional then 2 else 1
      let makeLayers () = Array.init numLayers (fun i -> if i = 0 then RNNCell(inFeatures, outFeatures, ?nonlinearity=nonlinearity, ?bias=bias) else RNNCell(outFeatures, outFeatures, ?nonlinearity=nonlinearity, ?bias=bias))
      let layers = makeLayers()
  
negative.code: dsharp.config(backend=Backend.Torch, device=Device.CPU)
  dsharp.seed(1)
  
  let rnnShape (value:Tensor) inFeatures batchFirst =
      let value =
          if batchFirst then
              if value.dim <> 3 then failwithf "Expecting the input to be of shape batchSize x seqLen x inFeatures, but received input with shape %A" value.shape
              value.transpose(0, 1)
          else
              if value.dim <> 3 then failwithf "Expecting the input to be of shape seqLen x batchSize x inFeatures, but received input with shape %A" value.shape
              value
      if value.shape.[2] <> inFeatures then failwithf "Expecting input to have %A features, but received input with shape %A" inFeatures value.shape
      let seqLen, batchSize = value.shape.[0], value.shape.[1]
      value, seqLen, batchSize
  
  
  type RNNCell(inFeatures, outFeatures, ?nonlinearity, ?bias, ?batchFirst) =
      inherit Model()
      let nonlinearity = defaultArg nonlinearity dsharp.tanh
      let bias = defaultArg bias true
      let batchFirst = defaultArg batchFirst false
      let k = 1./sqrt (float outFeatures)
      let wih = Parameter(Weight.uniform([|inFeatures; outFeatures|], k))
      let whh = Parameter(Weight.uniform([|outFeatures; outFeatures|], k))
  