code: def _ensure_session(self, session=None):
          
          if session:
              return session
  
          try:
              # Don't make implicit sessions causally consistent. Applications
              # should always opt-in.
              return self.__start_session(True, causal_consistency=False)
          except (ConfigurationError, InvalidOperation):
              # Sessions not supported, or multiple users authenticated.
              return None
docs: If provided session is None, lend a temporary session.