testConcatRunAndVerifyGradientsRandom :: Test
testConcatRunAndVerifyGradientsRandom = testCase "testConcatRunAndVerifyGradientsRandom" $
    forM_ [1..5 :: Int] $ \_ -> do
        (shapes' :: [Int64]) <- replicateM 5 $ randomRIO (1, 5)
        (numTensors :: Int)  <- randomRIO (2, 10)
        (concatDim :: Int)   <- randomRIO (-4, 4)
        (concatDimSizes :: [Int64]) <- replicateM numTensors $ randomRIO (1, 5)
        let update i xs x = take i xs ++ x: drop (i+1) xs
            concatDim'    = concatDim `mod` length shapes'
            shapes        = map (update concatDim' shapes') concatDimSizes
        verifyConcatGradients shapes $ fromIntegral concatDim

-- run single test like this:
-- stack --docker --docker-image=$IMAGE_NAME test tensorflow-ops:GradientTest --test-arguments -t"*MaximumGrad*"
testConcatRunAndVerifyGradientsRandom :: Test
testConcatRunAndVerifyGradientsRandom = testCase "testConcatRunAndVerifyGradientsRandom" $
    forM_ [1..5 :: Int] $ \_ -> do
        (shapes' :: [Int64]) <- replicateM 5 $ randomRIO (1, 5)
        (numTensors :: Int)  <- randomRIO (2, 10)
        (concatDim :: Int)   <- randomRIO (-4, 4)
        (concatDimSizes :: [Int64]) <- replicateM numTensors $ randomRIO (1, 5)
        let update i xs x = take i xs ++ x: drop (i+1) xs
            concatDim'    = concatDim `mod` length shapes'
            shapes        = map (update concatDim' shapes') concatDimSizes
        verifyConcatGradients shapes $ fromIntegral concatDim

-- run single test like this:
-- stack --docker --docker-image=$IMAGE_NAME test tensorflow-ops:GradientTest --test-arguments -t"*MaximumGrad*"
testConcatRunAndVerifyGradientsRandom = testCase "testConcatRunAndVerifyGradientsRandom" $
    forM_ [1..5 :: Int] $ \_ -> do
        (shapes' :: [Int64]) <- replicateM 5 $ randomRIO (1, 5)
        (numTensors :: Int)  <- randomRIO (2, 10)
        (concatDim :: Int)   <- randomRIO (-4, 4)
        (concatDimSizes :: [Int64]) <- replicateM numTensors $ randomRIO (1, 5)
        let update i xs x = take i xs ++ x: drop (i+1) xs
            concatDim'    = concatDim `mod` length shapes'
            shapes        = map (update concatDim' shapes') concatDimSizes
        verifyConcatGradients shapes $ fromIntegral concatDim

-- run single test like this:
-- stack --docker --docker-image=$IMAGE_NAME test tensorflow-ops:GradientTest --test-arguments -t"*MaximumGrad*"