code: def _create_next_token_logits_penalties(
      input_ids, logits, repetition_penalty
  ):
      # create logit penalties for already seen input_ids
      token_penalties = np.ones(shape_list(logits))
      prev_input_ids = [
          np.unique(input_id) for input_id in input_ids.numpy()
      ]
      for i, prev_input_id in enumerate(prev_input_ids):
          logit_penalized = logits[i].numpy()[prev_input_id]
          logit_penalties = np.zeros(logit_penalized.shape)
          # if previous logit score is < 0 then multiply repetition penalty else divide
          logit_penalties[logit_penalized < 0] = repetition_penalty
          logit_penalties[logit_penalized > 0] = 1 / repetition_penalty
          np.put(token_penalties[i], prev_input_id, logit_penalties)
      return tf.convert_to_tensor(token_penalties, dtype=tf.float32)
  
imports: import inspect
  import warnings
  from dataclasses import dataclass
  from typing import Any, Dict, List, Optional, Tuple, Union
  import numpy
  import tensorflow
  from tensorflow.compiler.tf2xla.python.xla import dynamic_update_slice
  from .generation_tf_logits_process import TFForcedBOSTokenLogitsProcessor, TFForcedEOSTokenLogitsProcessor, TFForceTokensLogitsProcessor, TFLogitsProcessorList, TFMinLengthLogitsProcessor, TFNoBadWordsLogitsProcessor, TFNoRepeatNGramLogitsProcessor, TFRepetitionPenaltyLogitsProcessor, TFSuppressTokensAtBeginLogitsProcessor, TFSuppressTokensLogitsProcessor, TFTemperatureLogitsWarper, TFTopKLogitsWarper, TFTopPLogitsWarper
  from .models.auto import TF_MODEL_FOR_CAUSAL_LM_MAPPING, TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING, TF_MODEL_FOR_SPEECH_SEQ_2_SEQ_MAPPING, TF_MODEL_FOR_VISION_2_SEQ_MAPPING
  from .tf_utils import shape_list, stable_softmax
  from .utils import ModelOutput, logging
label_desc: Use image node_id 1 for calling a global function with example usage: _create_next_token_logits_penalties(input_ids, logits, repetition_penalty) and returns: tf