anchor.diff:          else
               let mutable x = x
               for i in 0..n-1 do
  -                x <- x |> DiffSharp.forwardDiff (GlobalNestingLevel.Next()) v.[i]
  +                x <- x |> dsharp.forwardDiff (GlobalNestingLevel.Next()) v.[i]
               let mutable fx = f x
               [|for _ in 0..n-1 do
                   let d = fx.derivativeDeep
  
positive.code:     static member reverseReset (tensor:Tensor) = tensor.reverseReset(true)
      static member reversePush (value:Tensor) (tensor:Tensor) = tensor.reversePush(value)
      static member reverse (value:Tensor) (tensor:Tensor) = tensor.reverse(value)
      static member evalForwardDiff f x v = x |> DiffSharp.forwardDiff (GlobalNestingLevel.Next()) v |> f |> DiffSharp.primalDerivative
      static member evalReverseDiff f x =
          let x = x |> DiffSharp.reverseDiff (GlobalNestingLevel.Next())
          let fx = f x
          let r = fun v -> fx |> DiffSharp.reverse v; x.derivative
          fx.primal, r
      static member evalForwardDiffs (f:Tensor->Tensor) x (v:Tensor[]) =
          let n = v.Length
  
negative.code:         dtype |> Option.iter (fun d -> Dtype.Default <- d)
          device |> Option.iter (fun d -> Device.Default <- d)
          backend |> Option.iter (fun d -> Backend.Default <- d)
          dsharp.tensor(0.) |> ignore // We need this to ensure the backend assemblies are loaded and backend is ready to set the random seed immediately after config
  
      static member config() = Dtype.Default, Device.Default, Backend.Default
      static member config((dtype,device,backend)) = dsharp.config(dtype, device, backend)
      static member devices(?deviceType, ?backend) = BackendStatics.Get(?backend=backend).GetDevices(?deviceType=deviceType)
      static member isDeviceTypeSupported(deviceType, ?backend) = BackendStatics.Get(?backend=backend).IsDeviceTypeSupported(deviceType)
      static member isCudaSupported(?backend) = BackendStatics.Get(?backend=backend).IsDeviceTypeSupported(DeviceType.CUDA)
  
  // Methods mirroring F# array modules
  // TODO: implement more differentiable higher-order functions and corresponding unit tests for their derivatives
  type dsharp with
      static member init (count:int) (initializer:int->'a) = Array.init count initializer |> dsharp.tensor
      static member init2d (length1:int) (length2:int) (initializer:int->int->'a) = Array2D.init length1 length2 initializer |> dsharp.tensor
      static member init3d (length1:int) (length2:int) (length3:int) (initializer:int->int->int->'a) = Array3D.init length1 length2 length3 initializer |> dsharp.tensor
      static member init4d (length1:int) (length2:int) (length3:int) (length4:int) (initializer:int->int->int->int->'a) = Array4D.init length1 length2 length3 length4 initializer |> dsharp.tensor
      static member create (count:int) (value:'a) = Array.create count value |> dsharp.tensor
      static member zeroCreate (count:int) = Array.zeroCreate count |> dsharp.tensor
      static member mapi (mapping:int[]->Tensor->Tensor) (tensor:Tensor) = // Differentiable map
          let tflat = tensor.view(-1)
          let items = Array.init (tflat.nelement) (fun i -> mapping (flatIndexToIndex tensor.shape i) tflat.[i])
          dsharp.stack(items).view(tensor.shape)
      static member mapi2 (mapping:int[]->Tensor->Tensor->Tensor) (tensor1:Tensor) (tensor2:Tensor) =  // Differentiable map2
          if tensor1.shape <> tensor2.shape then failwithf "Expecting tensor1.shape (%A) and tensor2.shape (%A) to be the same" tensor1.shape tensor2.shape
          let tflat1 = tensor1.view(-1)
          let tflat2 = tensor2.view(-1)
          let items = Array.init (tflat1.nelement) (fun i -> mapping (flatIndexToIndex tensor1.shape i) tflat1.[i] tflat2.[i])
          dsharp.stack(items).view(tensor1.shape)
      static member mapi3 (mapping:int[]->Tensor->Tensor->Tensor->Tensor) (tensor1:Tensor) (tensor2:Tensor) (tensor3:Tensor) =  // Differentiable map3
          if (tensor1.shape <> tensor2.shape) || (tensor2.shape <> tensor3.shape) then failwithf "Expecting tensor1.shape (%A), tensor2.shape (%A), tensor3.shape (%A) to be the same" tensor1.shape tensor2.shape tensor3.shape
          let tflat1 = tensor1.view(-1)
          let tflat2 = tensor2.view(-1)
          let tflat3 = tensor3.view(-1)
          let items = Array.init (tflat1.nelement) (fun i -> mapping (flatIndexToIndex tensor1.shape i) tflat1.[i] tflat2.[i] tflat3.[i])
          dsharp.stack(items).view(tensor1.shape)
      static member map (mapping:Tensor->Tensor) (tensor:Tensor) = tensor |> dsharp.mapi (fun _ v -> mapping v)
      static member map2 (mapping:Tensor->Tensor->Tensor) (tensor1:Tensor) (tensor2:Tensor) = dsharp.mapi2 (fun _ v1 v2 -> mapping v1 v2) tensor1 tensor2
      static member map3 (mapping:Tensor->Tensor->Tensor->Tensor) (tensor1:Tensor) (tensor2:Tensor) (tensor3:Tensor) = dsharp.mapi3 (fun _ v1 v2 v3 -> mapping v1 v2 v3) tensor1 tensor2 tensor3
  
  
  // Functional automatic differentiation API
  type dsharp with
      static member nest() = GlobalNestingLevel.Next() |> ignore
      static member nest(level) = GlobalNestingLevel.Set(level)
      static member nestLevel() = GlobalNestingLevel.Current
  