code: def _compute_direction_numbers(dim):
      """Returns array of direction numbers for dimension dim.
  
      These are the m_kj values in the Joe & Kuo notes[1], not the v_kj values. So
      these refer to the 'abuse of notation' mentioned in the notes -- it is a
      matrix of integers, not floats. The variable names below are intended to match
      the notation in the notes as closely as possible.
  
      Args:
        dim: int, dimension.
  
      Returns:
        `numpy.array` of direction numbers with `shape` [dim, 32].
      """
      m = np.empty((dim, 32), dtype=np.int32)
      m[0, :] = np.ones(32, dtype=np.int32)
      for k in range(dim - 1):
          a_k = _PRIMITIVE_POLYNOMIAL_COEFFICIENTS[k]
          deg = np.int32(np.floor(np.log2(a_k)))  # degree of polynomial
          m[k + 1, :deg] = _INITIAL_DIRECTION_NUMBERS[:deg, k]
          for j in range(deg, 32):
              m[k + 1, j] = m[k + 1, j - deg]
              for i in range(deg):
                  if (a_k >> i) & 1:
                      m[k + 1, j] = np.bitwise_xor(
                          m[k + 1, j],
                          m[k + 1, j - deg + i] << (deg - i),
                      )
      return m
  
file_path: tf-quant-finance/tf_quant_finance/math/random_ops/sobol/sobol_impl.py
imports: import logging
  import os
  from typing import Optional, Tuple
  import numpy
  from six.moves import range
  import tensorflow.compat.v2
  from tf_quant_finance import types
label_desc: Use image node_id 2 for calling a global function with example usage: _compute_direction_numbers(dim) and returns: m