code: def test_constrained_parafac_monotonicity():
      """Test for the CANDECOMP-PARAFAC decomposition with ADMM under monotonicity constraints"""
      rng = T.check_random_state(1234)
      rank = 3
      init = "random"
      tensor_init = initialize_constrained_parafac(
          T.zeros([6, 8, 4]), rank, monotonicity=True, init=init
      )
      tensor = cp_to_tensor(tensor_init)
      _, factors = constrained_parafac(
          tensor,
          monotonicity=True,
          rank=rank,
          init=tensor_init,
          random_state=rng,
      )
      # Testing if estimated factors are monotonic
      for factor in factors:
          assert_(np.all(np.diff(T.to_numpy(factor), axis=0) >= 0))
  
file_path: tensorly/tensorly/decomposition/tests/test_constrained_parafac.py
imports: import numpy
  from ...cp_tensor import cp_to_tensor, CPTensor
  from .._constrained_cp import constrained_parafac, initialize_constrained_parafac, ConstrainedCP
  from ...None import backend
  from ...testing import assert_, assert_array_almost_equal, assert_class_wrapper_correctly_passes_arguments
  from ...random import random_cp
label_desc: Use image node_id 5 for calling a global function with example usage: test_constrained_parafac_monotonicity() without return types