code: def from_session(cls, session):
          
          session.error_wrapper = lambda e: NvimError(e[1])
          channel_id, metadata = session.request(b'vim_get_api_info')
  
          if IS_PYTHON3:
              # decode all metadata strings for python3
              metadata = walk(decode_if_bytes, metadata)
  
          types = {
              metadata['types']['Buffer']['id']: Buffer,
              metadata['types']['Window']['id']: Window,
              metadata['types']['Tabpage']['id']: Tabpage,
          }
  
          return cls(session, channel_id, metadata, types)
docs: Create a new Nvim instance for a Session instance.
  
          This method must be called to create the first Nvim instance, since it
          queries Nvim metadata for type information and sets a SessionHook for
          creating specialized objects from Nvim remote handles.