code: def create_session(
      config_dict: dict = None, force_as_default: bool = False
  ) -> tf.Session:
      """Create tf.Session based on config dict."""
      # Setup TensorFlow config proto.
      cfg = _sanitize_tf_config(config_dict)
      config_proto = tf.ConfigProto()
      for key, value in cfg.items():
          fields = key.split(".")
          if fields[0] not in ["rnd", "env"]:
              obj = config_proto
              for field in fields[:-1]:
                  obj = getattr(obj, field)
              setattr(obj, fields[-1], value)
  
      # Create session.
      session = tf.Session(config=config_proto)
      if force_as_default:
          # pylint: disable=protected-access
          session._default_session = session.as_default()
          session._default_session.enforce_nesting = False
          session._default_session.__enter__()
      return session
  
imports: import os
  import numpy
  import tensorflow
  import logging
  import tensorflow.contrib
  from typing import Any, Iterable, List, Union
label_desc: Use image node_id 14 for calling a global function with example usage: create_session(config_dict, force_as_default) and returns: session