code: def maybe_name_or_idx(idx, model):
      """
      Give a name or an integer and return the name and integer location of the
      column in a design matrix.
      """
      if idx is None:
          idx = lrange(model.exog.shape[1])
      if isinstance(idx, int):
          exog_name = model.exog_names[idx]
          exog_idx = idx
      # anticipate index as list and recurse
      elif isinstance(idx, (tuple, list)):
          exog_name = []
          exog_idx = []
          for item in idx:
              exog_name_item, exog_idx_item = maybe_name_or_idx(
                  item, model
              )
              exog_name.append(exog_name_item)
              exog_idx.append(exog_idx_item)
      else:  # assume we've got a string variable
          exog_name = idx
          exog_idx = model.exog_names.index(idx)
  
      return exog_name, exog_idx
  
imports: from statsmodels.compat.python import lrange
label_desc: Use image node_id 4 for calling a global function with example usage: maybe_name_or_idx(idx, model) and returns: exog_name,  exog_idx