code: def apply_brightness_shift(x, brightness, scale=True):
      """Performs a brightness shift.
  
      # Arguments
          x: Input tensor. Must be 3D.
          brightness: Float. The new brightness value.
          scale: Whether to rescale the image such that minimum and maximum values
              are 0 and 255 respectively.
              Default: True.
  
      # Returns
          Numpy image tensor.
  
      # Raises
          ImportError: if PIL is not available.
      """
      if ImageEnhance is None:
          raise ImportError(
              "Using brightness shifts requires PIL. "
              "Install PIL or Pillow."
          )
      x_min, x_max = np.min(x), np.max(x)
      local_scale = (x_min < 0) or (x_max > 255)
      x = array_to_img(x, scale=local_scale or scale)
      x = imgenhancer_Brightness = ImageEnhance.Brightness(x)
      x = imgenhancer_Brightness.enhance(brightness)
      x = img_to_array(x)
      if not scale and local_scale:
          x = x / 255 * (x_max - x_min) + x_min
      return x
  
file_path: keras-preprocessing/keras_preprocessing/image/affine_transformations.py
imports: import numpy
  from .utils import array_to_img, img_to_array
label_desc: Use image node_id 8 for calling a global function with example usage: apply_brightness_shift(x, brightness, scale) and returns: x