code: def _create_position_ids_from_input_ids(
      input_ids: tf.Tensor,
      past_key_values_length: int,
      padding_idx: Optional[int],
  ) -> tf.Tensor:
      """
      Replace non-padding symbols with their position numbers. Position numbers begin at padding_idx+1. Padding symbols
      are ignored. This is modified from fairseq's `utils.make_positions`.
      """
      # The series of casts and type-conversions here are carefully balanced to both work with ONNX export and XLA.
      mask = tf.where(input_ids != padding_idx, 1, 0)
      incremental_indices = (
          tf.cast(tf.cumsum(mask, axis=1), dtype=mask.dtype)
          + past_key_values_length
      ) * mask
      return tf.cast(incremental_indices, dtype=tf.int64) + padding_idx
  
imports: import math
  import random
  from typing import Any, Optional, Tuple, Union
  import numpy
  import tensorflow
  from ...activations_tf import get_tf_activation
  from ...file_utils import DUMMY_INPUTS, add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward, replace_return_docstrings
  from ...modeling_tf_outputs import TFBaseModelOutputWithPastAndCrossAttentions, TFCausalLMOutputWithCrossAttentions
  from ...modeling_tf_utils import TFCausalLanguageModelingLoss, TFModelInputType, TFPreTrainedModel, TFSharedEmbeddings, get_initializer, keras_serializable, unpack_inputs
  from ...tf_utils import shape_list, stable_softmax
  from ...utils import logging
  from .configuration_xglm import XGLMConfig
label_desc: Use image node_id 2 for calling a global function with example usage: _create_position_ids_from_input_ids(input_ids, past_key_values_length, padding_idx) and returns: unknown