code: def is_valid_regex(regex):
      """Helper function to determine whether the provided regex is valid.
  
      Args:
          regex (str): The user provided regex.
  
      Returns:
          bool: Indicates whether the provided regex was valid or not.
  
      """
      try:
          re.compile(regex)
          return True
      except (re.error, TypeError):
          return False
  
file_path: sagemaker-python-sdk/src/sagemaker/debugger/utils.py
imports: from __future__ import absolute_import
  import re
  from datetime import datetime
  from enum import Enum
label_desc: Use image node_id 4 for calling a global function with example usage: is_valid_regex(regex) and returns: True, False