code: def skipgrams(sequence, n, k, **kwargs):
      """
      Returns all possible skipgrams generated from a sequence of items, as an iterator.
      Skipgrams are ngrams that allows tokens to be skipped.
      Refer to http://homepages.inf.ed.ac.uk/ballison/pdf/lrec_skipgrams.pdf
  
          >>> sent = "Insurgents killed in ongoing fighting".split()
          >>> list(skipgrams(sent, 2, 2))
          [('Insurgents', 'killed'), ('Insurgents', 'in'), ('Insurgents', 'ongoing'), ('killed', 'in'), ('killed', 'ongoing'), ('killed', 'fighting'), ('in', 'ongoing'), ('in', 'fighting'), ('ongoing', 'fighting')]
          >>> list(skipgrams(sent, 3, 2))
          [('Insurgents', 'killed', 'in'), ('Insurgents', 'killed', 'ongoing'), ('Insurgents', 'killed', 'fighting'), ('Insurgents', 'in', 'ongoing'), ('Insurgents', 'in', 'fighting'), ('Insurgents', 'ongoing', 'fighting'), ('killed', 'in', 'ongoing'), ('killed', 'in', 'fighting'), ('killed', 'ongoing', 'fighting'), ('in', 'ongoing', 'fighting')]
  
      :param sequence: the source data to be converted into trigrams
      :type sequence: sequence or iter
      :param n: the degree of the ngrams
      :type n: int
      :param k: the skip distance
      :type  k: int
      :rtype: iter(tuple)
      """
  
      # Pads the sequence as desired by **kwargs.
      if "pad_left" in kwargs or "pad_right" in kwargs:
          sequence = pad_sequence(sequence, n, **kwargs)
  
      # Note when iterating through the ngrams, the pad_right here is not
      # the **kwargs padding, it's for the algorithm to detect the SENTINEL
      # object on the right pad to stop inner loop.
      SENTINEL = object()
      for ngram in ngrams(
          sequence, n + k, pad_right=True, right_pad_symbol=SENTINEL
      ):
          head = ngram[:1]
          tail = ngram[1:]
          for skip_tail in combinations(tail, n - 1):
              if skip_tail[-1] is SENTINEL:
                  continue
              yield head + skip_tail
  
imports: import inspect
  import locale
  import os
  import pydoc
  import re
  import textwrap
  import unicodedata
  import warnings
  from collections import defaultdict, deque
  from itertools import chain, combinations, islice, tee
  from pprint import pprint
  from urllib.request import HTTPPasswordMgrWithDefaultRealm, ProxyBasicAuthHandler, ProxyDigestAuthHandler, ProxyHandler, build_opener, getproxies, install_opener
  from nltk.collections import *
  from nltk.internals import deprecated, raise_unorderable_types, slice_bounds
label_desc: Use image node_id 32 for calling a global function with example usage: skipgrams(sequence, n, k) without return types