code: def _generate_trajectory(
      group_membership: np.ndarray, num_levels: int = 4
  ) -> np.ndarray:
      """Return a single trajectory
  
      Return a single trajectory of size :math:`(g+1)`-by-:math:`k`
      where :math:`g` is the number of groups,
      and :math:`k` is the number of factors,
      both implied by the dimensions of `group_membership`
  
      Parameters
      ---------
      group_membership : np.ndarray
          a k-by-g matrix which notes factor membership of groups
      num_levels : int, default=4
          The number of levels in the grid
  
      Returns
      -------
      np.ndarray
      """
  
      delta = _compute_delta(num_levels)
  
      # Infer number of groups `g` and number of params `k` from
      # `group_membership` matrix
      num_params = group_membership.shape[0]
      num_groups = group_membership.shape[1]
  
      # Matrix B - size (g + 1) * g -  lower triangular matrix
      B = np.tril(np.ones([num_groups + 1, num_groups], dtype=int), -1)
  
      P_star = _generate_p_star(num_groups)
  
      # Matrix J - a (g+1)-by-num_params matrix of ones
      J = np.ones((num_groups + 1, num_params))
  
      # Matrix D* - num_params-by-num_params matrix which describes whether
      # factors move up or down
      D_star = np.diag(rd.choice([-1, 1], num_params))
  
      x_star = _generate_x_star(num_params, num_levels)
  
      # Matrix B* - size (num_groups + 1) * num_params
      B_star = _compute_b_star(
          J, x_star, delta, B, group_membership, P_star, D_star
      )
  
      return B_star
  
imports: import numpy
  from typing import Dict
  import numpy.random
  import warnings
  from .local import LocalOptimisation
  from .brute import BruteForce
  from .strategy import SampleMorris
  from SALib.sample import common_args
  from SALib.util import scale_samples, read_param_file, compute_groups_matrix, _define_problem_with_groups, _compute_delta, _check_groups
label_desc: Use image node_id 3 for calling a global function with example usage: _generate_trajectory(group_membership, num_levels) and returns: B_star