class_docstr: N-gram layer.
  
  The layer takes as input an integer Tensor of shape [..., length], each
  element of which is a token index in [0, input_dim). It returns a real-valued
  Tensor of shape [..., num_ngrams], counting the number of times each n-gram
  appears in a batch element. The total number of n-grams is
  
  ```none
  num_ngrams = \sum_{minval <= n < maxval} input_dim^n.
  ```
class_docstr_tok: ["N-gram","layer",".","The","layer","takes","as","input","an","integer","Tensor","of","shape","[","...",",","length","]",",","each","element","of","which","is","a","token","index","in","[","0",",","input_dim",")",".","It","returns","a","real-valued","Tensor","of","shape","[","...",",","num_ngrams","]",",","counting","the","number","of","times","each","n-gram","appears","in","a","batch","element",".","The","total","number","of","n-grams","is","``","`","none","num_ngrams","=","\\sum_","{","minval","<","=","n","<","maxval","}","input_dim^n",".","``","`"]
docstr: Constructs layer.
  
  Args:
    input_dim: int > 0. Size of the vocabulary, i.e. maximum integer index +
      1.
    minval: Lowest inclusive value of n for computing n-grams. For example,
      setting it to 1 will compute starting from unigrams.
    maxval: Highest non-inclusive value of n for computing n-grams. For
      example, setting it to 3 will compute at most bigrams.
    **kwargs: kwargs of parent class.
docstr_tok: ["Constructs","layer",".","Args",":","input_dim",":","int",">","0",".","Size","of","the","vocabulary",",","i.e",".","maximum","integer","index","+","1.","minval",":","Lowest","inclusive","value","of","n","for","computing","n-grams",".","For","example",",","setting","it","to","1","will","compute","starting","from","unigrams",".","maxval",":","Highest","non-inclusive","value","of","n","for","computing","n-grams",".","For","example",",","setting","it","to","3","will","compute","at","most","bigrams",".","*","*","kwargs",":","kwargs","of","parent","class","."]
code: def __init__(self, input_dim, minval, maxval, **kwargs):
      """Constructs layer.
  
      Args:
        input_dim: int > 0. Size of the vocabulary, i.e. maximum integer index +
          1.
        minval: Lowest inclusive value of n for computing n-grams. For example,
          setting it to 1 will compute starting from unigrams.
        maxval: Highest non-inclusive value of n for computing n-grams. For
          example, setting it to 3 will compute at most bigrams.
        **kwargs: kwargs of parent class.
      """
      super(NGram, self).__init__(**kwargs)
      self.input_dim = input_dim
      self.minval = minval
      self.maxval = maxval
  
file_path: tensor2tensor/tensor2tensor/layers/ngram.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import numpy
  import tensorflow.compat.v1
label_desc: Use image node_id 1 to create a new NGram object from inherited base classes: tf.keras.layers with example: obj = NGram(input_dim, minval, maxval)