text: from abc import abstractmethod
  
  import tensorflow as tf
  
  
  class ImgFeatureExtractor:
  
      # Kitti image mean per channel
      _R_MEAN = 92.8403
      _G_MEAN = 97.7996
      _B_MEAN = 93.5843
  
      def __init__(self, extractor_config):
          self.config = extractor_config
  
      def preprocess_input(self, tensor_in):
          """Preprocesses the given input.
  
          Args:
              tensor_in: A `Tensor` of shape=(batch_size, height,
                  width, channels) representing an input image.
  
          Returns:
              Preprocessed tensor input
          """
          image = tf.to_float(tensor_in)
          image_normalized = self._mean_image_subtraction(
              image, [self._R_MEAN, self._G_MEAN, self._B_MEAN]
          )
          return image_normalized
  
      def _mean_image_subtraction(self, image, means):
          """Subtracts the given means from each image channel.
  
          For example:
          means = [123.68, 116.779, 103.939]
          image = _mean_image_subtraction(image, means)
  
          Note that the rank of `image` must be known.
  
          Args:
          image: a tensor of size [height, width, C].
          means: a C-vector of values to subtract from each channel.
  
          Returns:
          the centered image.
  
          Raises:
          ValueError: If the rank of `image` is unknown, if `image` has a rank
              other than three or if the number of channels in `image` doesn't
              match the number of values in `means`.
          """
          if image.get_shape().ndims != 4:
              raise ValueError("Input must be of size [batch, height, width, C>0]")
          num_channels = image.get_shape().as_list()[-1]
          if len(means) != num_channels:
              raise ValueError("len(means) must match the number of channels")
  
          channels = tf.split(axis=3, num_or_size_splits=num_channels, value=image)
          for i in range(num_channels):
              channels[i] -= means[i]
          return tf.concat(axis=3, values=channels)
  
      @abstractmethod
      def build(self, **kwargs):
          pass
  