code: def random_sample_sequence_with_centre(
      sequence: tf.Tensor,
      num_steps: int,
      stride: int = 1,
      seed: Optional[int] = None,
      state: Optional[builders.ProcessorState] = None,
  ) -> tf.Tensor:
      """Samples a single segment of size `num_steps` from a given sequence.
  
      The segment is randomly chosen such that it contains the middle element
      of the sequence.
  
      Args:
        sequence: Any tensor where the first dimension is timesteps.
        num_steps: Number of steps (e.g. frames) to take.
        stride: Distance to sample between timesteps.
        seed: A deterministic seed to use when sampling.
        state: A mutable dictionary where keys are strings. The dictionary might
          contain 'sample_offset_proportion' as key with metadata useful for
          sampling. It will be modified with added metadata if needed. This can be
          used to keep consistency between sampling of different sequences.
  
      Returns:
        A single tensor with first dimension `num_steps` with the sampled segment.
      """
      sequence_length = tf.shape(input=sequence)[0]
      offset_lower_bound = tf.maximum(
          sequence_length / 2 - num_steps * stride, 0
      )
      offset_upper_bound = sequence_length / 2
  
      offset = tf.random.uniform(
          (),
          minval=tf.cast(offset_lower_bound, dtype=tf.int32),
          maxval=tf.cast(offset_upper_bound, dtype=tf.int32),
          dtype=tf.int32,
          seed=seed,
      )  # Samples from [lower_bound, upper_bound)
  
      indices = dmvr_processors.sample_or_pad_sequence_indices(
          sequence=sequence,
          num_steps=num_steps,
          repeat_sequence=True,  # Will repeat the sequence if we request more.
          stride=stride,
          offset=offset,
      )
      indices.set_shape((num_steps,))
      output = tf.gather(sequence, indices)
  
      if state is not None:
          # Update state.
          sample_offset_proportion = tf.cast(
              offset, tf.float32
          ) / tf.cast(sequence_length, tf.float32)
          state["sample_offset_proportion"] = sample_offset_proportion
  
      return output
  
imports: import functools
  import math
  from typing import Optional
  from absl import logging
  from dmvr import builders
  from dmvr import processors
  import simclr.tf2.data_util
  import tensorflow
  from official.vision.image_classification import augment
label_desc: Use image node_id 13 for calling a global function with example usage: random_sample_sequence_with_centre(sequence, num_steps, stride, seed, state) and returns: output