code: def scramble_generating_matrices(
      generating_matrices: types.IntTensor,
      scrambling_matrices: types.IntTensor,
      num_digits: types.IntTensor,
      validate_args: bool = False,
      dtype: tf.DType = None,
      name: str = None,
  ):
      r"""Scrambles a generating matrix.
  
      #### Examples
  
      ```python
      import tf_quant_finance as tff
  
      # Example: Scrambling the 2D Sobol generating matrices.
  
      dim = 2
      num_results = 1000
      num_digits = 10
      seed = (2, 3)
  
      tff.math.qmc.scramble_generating_matrices(
          tff.math.qmc.sobol_generating_matrices(dim, num_results, num_digits),
          tff.math.qmc.random_scrambling_matrices(dim, num_digits, seed=seed),
          num_digits)
      # ==> tf.Tensor([
      #             [586, 505, 224, 102,  34,  31,  13,   6,   2,   1],
      #             [872, 695, 945, 531, 852, 663, 898, 568, 875, 693],
      #         ], shape=(2, 10), dtype=int32)
      ```
  
      Args:
        generating_matrices: Positive scalar `Tensor` of integers.
        scrambling_matrices: Positive Scalar `Tensor` of integers with the same
          `shape` as `generating_matrices`.
        num_digits: Positive scalar `Tensor` of integers with rank 0. The base-2
          precision of the points which can be sampled from `generating_matrices`.
        validate_args: Python `bool` indicating whether to validate arguments.
          Default value: `False`.
        dtype: Optional `dtype`. The `dtype` of the output `Tensor` (either `int32`
          or `int64`).
          Default value: `None` which maps to `generating_matrices.dtype`.
        name: Python `str` name prefixed to ops created by this function.
          Default value: `None` which maps to `scramble_generating_matrices`.
  
      Returns:
        A `Tensor` with the same `shape` and `dtype` as `generating_matrices`.
      """
  
      with tf.name_scope(name or "scramble_generating_matrices"):
          if dtype is None:
              generating_matrices = tf.convert_to_tensor(
                  generating_matrices
              )
  
          dtype = dtype or generating_matrices.dtype
  
          num_digits = tf.convert_to_tensor(
              num_digits, dtype=dtype, name="num_digits"
          )
  
          # shape: (dim, log_num_results)
          generating_matrices = tf.cast(
              generating_matrices,
              dtype=dtype,
              name="generating_matrices",
          )
  
          # shape: (dim, log_num_results)
          scrambling_matrices = tf.cast(
              scrambling_matrices,
              dtype=dtype,
              name="scrambling_matrices",
          )
  
          control_deps = []
          if validate_args:
              control_deps.append(
                  tf.debugging.assert_equal(
                      tf.rank(generating_matrices),
                      tf.rank(scrambling_matrices),
                      message="input matrices must have the same rank",
                  )
              )
              control_deps.append(
                  tf.debugging.assert_positive(
                      num_digits, message="num_digits must be positive"
                  )
              )
  
          with tf.control_dependencies(control_deps):
  
              def loop_predicate_fn(matrix, shift):
                  del matrix
                  return shift < num_digits
  
              def loop_body_fn(matrix, shift):
                  # shape: (dim, log_num_results)
                  shifted_scrambling_matrices = tf.bitwise.right_shift(
                      tf.gather(scrambling_matrices, [shift], axis=1),
                      shift,
                  )
  
                  # shape: (dim, log_num_results)
                  updated_matrix = tf.bitwise.bitwise_xor(
                      matrix,
                      utils.filter_tensor(
                          shifted_scrambling_matrices,
                          generating_matrices,
                          num_digits - 1 - shift,
                      ),
                  )
  
                  return (updated_matrix, shift + 1)
  
              matrix, _ = tf.while_loop(
                  loop_predicate_fn,
                  loop_body_fn,
                  loop_vars=(
                      tf.zeros_like(generating_matrices),
                      tf.constant(0, dtype=dtype),
                  ),
                  maximum_iterations=tf.cast(num_digits, tf.int32),
              )
  
              # shape: (dim, log_num_results)
              return matrix
  
file_path: tf-quant-finance/tf_quant_finance/math/qmc/digital_net.py
imports: import tensorflow.compat.v2
  from tf_quant_finance import types
  from tf_quant_finance.math.qmc import utils
label_desc: Use image node_id 5 for calling a global function with example usage: scramble_generating_matrices(generating_matrices, scrambling_matrices, num_digits, validate_args, dtype, name) and returns: matrix, unknown, updated_matrix,  unknown