code: def lattice_rule_sample(
      generating_vectors: types.IntTensor,
      dim: types.IntTensor,
      num_results: types.IntTensor,
      sequence_indices: types.IntTensor = None,
      additive_shift: types.FloatTensor = None,
      apply_tent_transform: bool = False,
      validate_args: bool = False,
      dtype: tf.DType = None,
      name: str = None,
  ) -> types.RealTensor:
      r"""Constructs a lattice rule from a generating vector.
  
      #### Examples
  
      ```python
      import tensorflow as tf
      import tf_quant_finance as tff
  
      # Example: Sampling 1,000 points from 2D generating vectors.
  
      generating_vectors = tf.constant([1, 387275, 314993, 50301], dtype=tf.int32)
  
      dim = 2
      num_results = 1000
  
      tff.math.qmc.lattice_rule_sample(generating_vectors, dim, num_results)
      # ==> tf.Tensor([
      #             [0.,         0.        ],
      #             [0.001,      0.2749939 ],
      #             [0.002,      0.5499878 ],
      #             ...
      #             [0.99700004, 0.1689148 ],
      #             [0.998,      0.4439087 ],
      #             [0.9990001,  0.7189026 ],
      #         ], shape=(1000, 2), dtype=float32)
      ```
  
      Args:
        generating_vectors: Positive scalar `Tensor` of integers with rank 1
          representing the vector from which to sample points.
        dim: Positive scalar `Tensor` of integers with rank 0. The event size of the
          sampled points. Must not exceed the size of `generating_vectors`.
        num_results: Positive scalar `Tensor` of integers with rank 0. The maximum
          number of points to sample.
        sequence_indices: Optional positive scalar `Tensor` of integers with rank 1.
          The elements of the sequence to return specified by their position in the
          sequence.
          Default value: `None` which corresponds to the `[0, num_results)` range.
        additive_shift: Optional scalar `Tensor` of real values with the same
          `shape` as `generating_vectors`. The additive shift to add to all the
          points (modulo 1) before applying the tent transform.
          Default value: `None`.
        apply_tent_transform: Python `bool` indicating whether to apply a tent
          transform to the sampled points.
          Default value: `False`.
        validate_args: Python `bool` indicating whether to validate arguments.
          Default value: `False`.
        dtype: Optional `dtype`. The `dtype` of the output `Tensor` (either
          `float32` or `float64`).
          Default value: `None` which maps to `float32`.
        name: Python `str` name prefixed to ops created by this function.
          Default value: `None` which maps to `sample_lattice_rule`.
  
      Returns:
        A `Tensor` of samples from  the Sobol sequence with `shape`
        `(num_samples,)` where `num_samples = min(num_results,
        size(sequence_indices))`.
      """
  
      with tf.name_scope(name or "sample_lattice_rule"):
          # shape: (?,)
          generating_vectors = tf.convert_to_tensor(
              generating_vectors, name="generating_vectors"
          )
  
          int_dtype = generating_vectors.dtype
          real_dtype = dtype or tf.float32
  
          dim = tf.convert_to_tensor(dim, dtype=int_dtype, name="dim")
          num_results = tf.convert_to_tensor(
              num_results, dtype=int_dtype, name="num_results"
          )
  
          control_deps = []
          if validate_args:
              control_deps.append(
                  tf.debugging.assert_equal(
                      tf.rank(generating_vectors),
                      1,
                      message="generating_vectors must have rank 1",
                  )
              )
              control_deps.append(
                  tf.debugging.assert_less_equal(
                      dim,
                      tf.size(generating_vectors, out_type=int_dtype),
                      message="dim must not exceed the size of generating_vectors",
                  )
              )
              control_deps.append(
                  tf.debugging.assert_positive(
                      num_results,
                      message="num_results must be positive",
                  )
              )
  
          with tf.control_dependencies(control_deps):
              # shape: (num_samples,)
              if sequence_indices is None:
                  sequence_indices = tf.range(0, num_results)
              sequence_indices = tf.cast(
                  sequence_indices, int_dtype, name="sequence_indices"
              )
  
              unit = tf.ones(shape=(), dtype=real_dtype)
  
              # shape: (dim,)
              scaled_vector = tf.divide(
                  # shape: (dim,)
                  tf.cast(generating_vectors[:dim], real_dtype),
                  # shape: ()
                  tf.cast(num_results, real_dtype),
              )
  
              # shape: (num_samples, dim)
              points = tf.multiply(
                  # shape: (num_samples, 1)
                  tf.expand_dims(
                      tf.cast(sequence_indices, real_dtype), axis=1
                  ),
                  # shape: (1, dim)
                  tf.expand_dims(
                      tf.math.floormod(scaled_vector, unit), axis=0
                  ),
              )
  
              if additive_shift is not None:
                  # shape: (num_results,)
                  additive_shift = tf.cast(
                      additive_shift, real_dtype, name="additive_shift"
                  )
                  # shape: (num_samples, dim)
                  points += additive_shift[:dim]
  
                  # shape: (num_samples, dim)
              points = tf.math.floormod(points, unit)
  
              # shape: (num_samples, dim)
              return (
                  utils.tent_transform(points)
                  if apply_tent_transform
                  else points
              )
  
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 2 for calling a global function with example usage: lattice_rule_sample(generating_vectors, dim, num_results, sequence_indices, additive_shift, apply_tent_transform, validate_args, dtype, name) and returns: unknown