code: def test_builder_to_backend_stress(
      self, use_cpu_only, backend, rank, prob, dynamic
  ):
      shape = np.random.randint(low=1, high=4, size=rank).astype(
          np.int32
      )
      x_val = np.array([0.0], dtype=np.float32)
      if dynamic:
          input_placeholders = {
              "x": mb.placeholder(shape=x_val.shape),
              "dyn_shape": mb.placeholder(
                  shape=shape.shape, dtype=types.int32
              ),
          }
          input_values = {"x": x_val, "dyn_shape": shape}
      else:
          input_placeholders = {"x": mb.placeholder(shape=x_val.shape)}
          input_values = {"x": x_val}
  
      def build(x):
          return [
              mb.add(x=x, y=x),
              mb.random_bernoulli(shape=shape, prob=prob),
          ]
  
      def build_dyn(x, dyn_shape):
          return [
              mb.add(x=x, y=x),
              mb.random_bernoulli(shape=dyn_shape, prob=prob),
          ]
  
      expected_outputs = [
          np.array(np.zeros(shape=(1,)), np.float32),
          np.random.binomial(1, prob, shape),
      ]
  
      if dynamic:
          expected_output_types = [
              tuple([UNK_SYM for _ in o.shape]) + (types.fp32,)
              for o in expected_outputs
          ]
      else:
          expected_output_types = [
              o.shape[:] + (types.fp32,) for o in expected_outputs
          ]
  
      builder = build_dyn if dynamic else build
  
      run_compare_builder(
          builder,
          input_placeholders,
          input_values,
          expected_output_types,
          expected_outputs=expected_outputs,
          use_cpu_only=use_cpu_only,
          backend=backend,
      )
  
file_path: turicreate/src/external/coremltools_wrap/coremltools/coremltools/converters/mil/mil/ops/tests/test_random.py
imports: from coremltools.converters.mil import testing_reqs
  from coremltools.converters.mil.testing_reqs import *
  from coremltools.converters.mil.testing_utils import get_core_ml_prediction
  from coremltools._deps import _IS_MACOS
  from .testing_utils import UNK_SYM, run_compare_builder
label_desc: Use image node_id 2 for calling the TestRandomBernoulli obj's underlying member method code with example usage: obj.test_builder_to_backend_stress(use_cpu_only, backend, rank, prob, dynamic) and returns: list, list