{"record":{"id":"cfe531fe123f6afe","repo":"tensorflow/models","slug":"axis-out-of-bounds-for-tensor-rank","errorCode":null,"errorMessage":"`axis` out of bounds for `tensor` rank.","messagePattern":"`axis` out of bounds for `tensor` rank\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/projects/triviaqa/inputs.py","lineNumber":115,"sourceCode":"    constant_values: For 'CONSTANT' mode, the scalar pad value to use within\n      `tf.pad`. Defaults to 0. Must be same type as `tensor`.\n    name: A name for the operation (optional).\n\n  Returns:\n    The padded Tensor result.\n  \"\"\"\n  with tf.name_scope(name or 'pad_to_multiple'):\n    tensor = tf.convert_to_tensor(tensor)\n\n    if isinstance(factor, int) and factor < 1:\n      raise ValueError('`factor` must be positive.')\n    rank = tensor.shape.rank\n    if rank is None:\n      raise ValueError('Static rank of `tensor` must be known.')\n    if axis < 0:\n      axis += rank\n    if axis < 0 or axis >= rank:\n      raise ValueError('`axis` out of bounds for `tensor` rank.')\n\n    axis_len = tf_utils.get_shape_list(tensor)[axis]\n    pad_len = -axis_len % factor\n    paddings = pad_len * tf.one_hot([-1, axis], rank, axis=0, dtype=tf.int32)\n    return tf.pad(\n        tensor=tensor,\n        paddings=paddings,\n        mode=mode,\n        constant_values=constant_values)\n\n\ndef _skew_elements_right(tensor: tf.Tensor,\n                         axis: int,\n                         pad_value=0,\n                         name: Optional[Text] = None) -> tf.Tensor:\n  \"\"\"Skews successive elements right along the given `axis`.\n\n  This changes an input like","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/projects/triviaqa/inputs.py#L97-L133","documentation":"Error \"`axis` out of bounds for `tensor` rank.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/projects/triviaqa/inputs.py:115 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e006f5f0d534913e49c1f1dae87364039fa607e2","analyzedAt":"2026-08-24T14:09:15.576Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}