code: def get_offsets(self, token_node_id=None, offset_ns=None):
          
          if offset_ns is None:
              offset_ns = self.ns
  
          try:
              if token_node_id is not None:
                  assert istoken(self, token_node_id), \
                      "'{}' is not a token node.".format(token_node_id)
                  onset = self.node[token_node_id]['{0}:{1}'.format(offset_ns, 'onset')]
                  offset = self.node[token_node_id]['{0}:{1}'.format(offset_ns, 'offset')]
                  return (onset, offset)
              else:  # return offsets for all tokens in the document
                  return self._get_all_offsets(offset_ns)
  
          # if the document doesn't have offsets: add them and rerun this method
          except KeyError as e:
              self.add_offsets(offset_ns)
              return self.get_offsets(token_node_id, offset_ns)
docs: returns the offsets (character starting and end position) of a token
          or of all tokens occurring in the document.
  
          Parameters
          ----------
          token_node_id : str, int or None
              Node ID of a token from which we want to retrieve the start and end
              position. If no node ID is given, this method will yield
              (token node ID, start pos, end pos) tuples containing data for all
              tokens in the document
          offset_ns : str or None
              The namespace from which the offsets will be retrieved. If no
              namespace is given, the default namespace of this document graph is
              chosen
  
          Returns
          -------
          offsets : tuple(int, int) or generator(tuple(str, int, int))
              If a token node ID is given, a (character onset int, character
              offset int) tuple is returned. Otherwise, a generator of (token
              node ID str, character onset int, character offset int) tuples
              will be returned, representing all the tokens in the order they
              occur in the document.