code: def _validate_kth_value(kth, size):
      kth = np.where(kth < 0, kth + size, kth)
      if np.any((kth < 0) | (kth >= size)):
          invalid_kth = next(k for k in kth if k < 0 or k >= size)
          raise ValueError(
              f"kth(={invalid_kth}) out of bounds ({size})"
          )
      return kth
  
imports: import itertools
  import numpy
  from ...None import opcodes
  from ...core import recursive_tile
  from ...serialization.serializables import FieldTypes, KeyField, Int32Field, StringField, ListField, BoolField, AnyField
  from ...utils import has_unknown_shape, flatten, stack_back
  from ...core import ENTITY_TYPE, ExecutableTuple
  from ..operands import TensorOperand, TensorShuffleProxy
  from ..core import TENSOR_TYPE, TENSOR_CHUNK_TYPE, TensorOrder
  from ..array_utils import as_same_device, device
  from ..datasource import tensor
  from ..utils import validate_axis, validate_order
  from .psrs import TensorPSRSOperandMixin
label_desc: Use image node_id 2 for calling a global function with example usage: _validate_kth_value(kth, size) and returns: kth