code: def _sample_morris(
      problem: Dict, number_trajectories: int, num_levels: int = 4
  ) -> np.ndarray:
      """Generate trajectories for groups
  
      Returns an :math:`N(g+1)`-by-:math:`k` array of `N` trajectories,
      where :math:`g` is the number of groups and :math:`k` is the number
      of factors
  
      Parameters
      ---------
      problem : dict
          The problem definition
      number_trajectories : int
          The number of trajectories to generate
      num_levels : int, default=4
          The number of grid levels
  
      Returns
      -------
      numpy.ndarray
      """
      groups = _check_groups(problem)
      group_membership, _ = compute_groups_matrix(groups)
      _check_group_membership(group_membership)
  
      num_params = group_membership.shape[0]
      num_groups = group_membership.shape[1]
  
      sample_morris = [
          _generate_trajectory(group_membership, num_levels)
          for _ in range(number_trajectories)
      ]
      sample_morris = np.array(sample_morris)
  
      return sample_morris.reshape(
          (number_trajectories * (num_groups + 1), num_params)
      )
  
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 2 for calling a global function with example usage: _sample_morris(problem, number_trajectories, num_levels) and returns: sample_morris