class_docstr: [`TFLogitsProcessor`] enforcing an exponential penalty on repeated sequences.
  
  Args:
      repetition_penalty (`float`):
          The parameter for repetition penalty. 1.0 means no penalty. See [this
          paper](https://arxiv.org/pdf/1909.05858.pdf) for more details.
class_docstr_tok: ["[","`","TFLogitsProcessor","`","]","enforcing","an","exponential","penalty","on","repeated","sequences",".","Args",":","repetition_penalty","(","`","float","`",")",":","The","parameter","for","repetition","penalty",".","1.0","means","no","penalty",".","See","[","this","paper","]","(","https",":","\/\/arxiv.org\/pdf\/1909.05858.pdf",")","for","more","details","."]
code: def _create_score_penalties(
      self, input_ids: tf.Tensor, logits: tf.Tensor
  ) -> tf.Tensor:
      # We want to populate the penalties in the positions of `input_ids`. Since XLA can't handle shapes unknown
      # before runtime, `tf.unique` can't be used. Therefore, we may have redundant updates, when a given row has
      # the same token multiple times.
  
      # Gathers the penalties to apply
      logit_penalties = tf.gather(
          logits, input_ids, axis=1, batch_dims=1
      )
      logit_penalties = tf.where(
          logit_penalties > 0, 1 / self.penalty, logit_penalties
      )
      logit_penalties = tf.where(
          logit_penalties < 0, self.penalty, logit_penalties
      )
  
      # Scatters the penalties
      token_penalties = tf.ones(logits.shape)
      batch_size = input_ids.shape[0]
      seq_len = tf.shape(input_ids)[
          1
      ]  # the sequence length has dynamic size, hence the dynamic shape
      indexable_prev_input_ids = tf.concat(
          (
              tf.expand_dims(
                  tf.repeat(tf.range(batch_size), seq_len), axis=-1
              ),
              tf.expand_dims(tf.reshape(input_ids, [-1]), axis=-1),
          ),
          axis=1,
      )
      token_penalties = tf.tensor_scatter_nd_update(
          token_penalties,
          indices=indexable_prev_input_ids,
          updates=tf.reshape(logit_penalties, [-1]),
      )
      return token_penalties
  
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 TFRepetitionPenaltyLogitsProcessor obj's underlying member method code with example usage: obj._create_score_penalties(input_ids, logits) and returns: token_penalties