code: def _compile_pattern(pattern):
      if pattern is None:
          return None
      try:
          return re.compile(pattern)
      except Exception as e:
          raise ValueError(
              f"invalid regular expression: {pattern!r}"
          ) from e
  
imports: import difflib
  import glob
  import logging
  import os
  import re
  from guild import util
label_desc: Use image node_id 1 for calling a global function with example usage: _compile_pattern(pattern) and returns: None, re