code: def compute_groups_matrix(groups):
      
      if not groups:
          return None
  
      num_vars = len(groups)
  
      # Get a unique set of the group names
      unique_group_names = list(OrderedDict.fromkeys(groups))
      number_of_groups = len(unique_group_names)
  
      indices = dict([(x, i) for (i, x) in enumerate(unique_group_names)])
  
      output = np.zeros((num_vars, number_of_groups), dtype=np.int)
  
      for parameter_row, group_membership in enumerate(groups):
          group_index = indices[group_membership]
          output[parameter_row, group_index] = 1
  
      return output, unique_group_names
docs: Generate matrix which notes factor membership of groups
  
      Computes a k-by-g matrix which notes factor membership of groups
      where:
          k is the number of variables (factors)
          g is the number of groups
      Also returns a g-length list of unique group_names whose positions
      correspond to the order of groups in the k-by-g matrix
  
      Arguments
      ---------
      groups : list
          Group names corresponding to each variable
  
      Returns
      -------
      tuple
          containing group matrix assigning parameters to
          groups and a list of unique group names