code: def get_pattern_cols(cols, pos_pattern=None, neg_pattern=None):
      """Get columns names from a list that matches ``pos_pattern``,
      but does not match ``neg_pattern``.
  
      If a column name matches both ``pos_pattern`` and ``neg_pattern``, it is excluded.
  
      Parameters
      ----------
      cols : `List` ['str']
          Usually column names of a DataFrame.
      pos_pattern : regular expression
          If column name matches this pattern, it is included in the output.
      neg_pattern : regular expression
          If column name matches this pattern, it is excluded from the output.
  
      Returns
      -------
      pattern_cols : `List` ['str']
          List of column names that match the pattern.
      """
      if pos_pattern is None:
          pos_pattern_cols = []
      else:
          pos_regex = re.compile(pos_pattern)
          pos_pattern_cols = [
              col for col in cols if pos_regex.findall(col)
          ]
      if neg_pattern is None:
          neg_pattern_cols = []
      else:
          neg_regex = re.compile(neg_pattern)
          neg_pattern_cols = [
              col for col in cols if neg_regex.findall(col)
          ]
  
      pattern_cols = [
          col
          for col in cols
          if col in pos_pattern_cols and col not in neg_pattern_cols
      ]
  
      return pattern_cols
  
imports: import copy
  import dataclasses
  import functools
  import math
  import re
  import warnings
  from dataclasses import field
  from typing import List
  import numpy
  import pandas
  from pandas.testing import assert_frame_equal
  from pandas.testing import assert_index_equal
  from pandas.testing import assert_series_equal
label_desc: Use image node_id 5 for calling a global function with example usage: get_pattern_cols(cols, pos_pattern, neg_pattern) and returns: pattern_cols