class_docstr: [`TFLogitsProcessor`] that enforces no repetition of n-grams. See
  [Fairseq](https://github.com/pytorch/fairseq/blob/a07cb6f40480928c9e0548b737aadd36ee66ac76/fairseq/sequence_generator.py#L345).
  
  Args:
      ngram_size (`int`):
          All ngrams of size `ngram_size` can only occur once.
class_docstr_tok: ["[","`","TFLogitsProcessor","`","]","that","enforces","no","repetition","of","n-grams",".","See","[","Fairseq","]","(","https",":","\/\/github.com\/pytorch\/fairseq\/blob\/a07cb6f40480928c9e0548b737aadd36ee66ac76\/fairseq\/sequence_generator.py","#","L345",")",".","Args",":","ngram_size","(","`","int","`",")",":","All","ngrams","of","size","`","ngram_size","`","can","only","occur","once","."]
code: def calc_banned_ngram_tokens(self, input_ids, num_hypos, cur_len):
      # Copied from fairseq for no_repeat_ngram in beam_search
      if cur_len + 1 < self.ngram_size:
          # return no banned tokens if we haven't generated ngram_size tokens yet
          return [[] for _ in range(num_hypos)]
      generated_ngrams = [{} for _ in range(num_hypos)]
      prev_input_ids = input_ids[:, :cur_len]
      for idx in range(num_hypos):
          gen_tokens = prev_input_ids[idx].numpy().tolist()
          generated_ngram = generated_ngrams[idx]
          for ngram in zip(
              *[gen_tokens[i:] for i in range(self.ngram_size)]
          ):
              prev_ngram_tuple = tuple(ngram[:-1])
              generated_ngram[prev_ngram_tuple] = generated_ngram.get(
                  prev_ngram_tuple, []
              ) + [ngram[-1]]
  
      def _get_generated_ngrams(hypo_idx):
          # Before decoding the next token, prevent decoding of ngrams that have already appeared
          start_idx = cur_len + 1 - self.ngram_size
          ngram_idx = tuple(
              prev_input_ids[hypo_idx, start_idx:cur_len]
              .numpy()
              .tolist()
          )
          return generated_ngrams[hypo_idx].get(ngram_idx, [])
  
      banned_tokens = [
          _get_generated_ngrams(hypo_idx)
          for hypo_idx in range(num_hypos)
      ]
  
      return banned_tokens
  
imports: import inspect
  from typing import List, Tuple
  import numpy
  import tensorflow
  from .tf_utils import stable_softmax
  from .utils import add_start_docstrings
  from .utils.logging import get_logger
label_desc: Use image node_id 2 for calling the TFNoRepeatNGramLogitsProcessor obj's underlying member method code with example usage: obj.calc_banned_ngram_tokens(input_ids, num_hypos, cur_len) and returns: banned_tokens, unknown, generated_ngrams