code: def ensure_dir_exists(directory):
      """Given a valid directory path, make sure it exists."""
      if dir:
          if not os.path.isdir(directory):
              os.makedirs(directory)
  
file_path: plotly.py/packages/python/chart-studio/chart_studio/utils.py
imports: from __future__ import absolute_import
  import os.path
  import re
  import threading
  import warnings
  import json
  from _plotly_utils.exceptions import PlotlyError
  from _plotly_utils.optional_imports import get_module
label_desc: Use image node_id 4 for calling a global function with example usage: ensure_dir_exists(directory) without return types