parameters: (np_img, transformation_matrix, mean_vector)
return_statement: return transformed_img
docstring: Apply linear transformation to the input NumPy image array, given a square transformation matrix and a mean_vector.
  
      The transformation first flattens the input array and subtract mean_vector from it, then computes the
      dot product with the transformation matrix, and reshapes it back to its original shape.
  
      Args:
          np_img (numpy.ndarray): NumPy image array of shape (C, H, W) to be linear transformed.
          transformation_matrix (numpy.ndarray): a square transformation matrix of shape (D, D), D = C x H x W.
          mean_vector (numpy.ndarray): a NumPy ndarray of shape (D,) where D = C x H x W.
  
      Returns:
          np_img (numpy.ndarray), Linear transformed image.
docstring_summary: Apply linear transformation to the input NumPy image array, given a square transformation matrix and a mean_vector.
docstring_tokens: Apply linear transformation to the input NumPy image array given a square transformation matrix and a mean_vector .
function: def linear_transform(np_img, transformation_matrix, mean_vector):
      """
      Apply linear transformation to the input NumPy image array, given a square transformation matrix and a mean_vector.
  
      The transformation first flattens the input array and subtract mean_vector from it, then computes the
      dot product with the transformation matrix, and reshapes it back to its original shape.
  
      Args:
          np_img (numpy.ndarray): NumPy image array of shape (C, H, W) to be linear transformed.
          transformation_matrix (numpy.ndarray): a square transformation matrix of shape (D, D), D = C x H x W.
          mean_vector (numpy.ndarray): a NumPy ndarray of shape (D,) where D = C x H x W.
  
      Returns:
          np_img (numpy.ndarray), Linear transformed image.
      """
      if not is_numpy(np_img):
          raise TypeError('img should be NumPy array. Got {}'.format(type(np_img)))
      if transformation_matrix.shape[0] != transformation_matrix.shape[1]:
          raise ValueError("transformation_matrix should be a square matrix. "
                           "Got shape {} instead".format(transformation_matrix.shape))
      if np.prod(np_img.shape) != transformation_matrix.shape[0]:
          raise ValueError("transformation_matrix shape {0} not compatible with "
                           "Numpy image shape {1}.".format(transformation_matrix.shape, np_img.shape))
      if mean_vector.shape[0] != transformation_matrix.shape[0]:
          raise ValueError("mean_vector length {0} should match either one dimension of the square "
                           "transformation_matrix {1}.".format(mean_vector.shape[0], transformation_matrix.shape))
      zero_centered_img = np_img.reshape(1, -1) - mean_vector
      transformed_img = np.dot(zero_centered_img, transformation_matrix)
      if transformed_img.size != np_img.size:
          raise ValueError("Linear transform failed, input shape should match with transformation_matrix.")
      transformed_img = transformed_img.reshape(np_img.shape)
      return transformed_img
function_tokens: def linear_transform ( np_img , transformation_matrix , mean_vector ) : if not is_numpy ( np_img ) : raise TypeError ( 'img should be NumPy array. Got {}' . format ( type ( np_img ) ) ) if transformation_matrix . shape [ 0 ] != transformation_matrix . shape [ 1 ] : raise ValueError ( "transformation_matrix should be a square matrix. " "Got shape {} instead" . format ( transformation_matrix . shape ) ) if np . prod ( np_img . shape ) != transformation_matrix . shape [ 0 ] : raise ValueError ( "transformation_matrix shape {0} not compatible with " "Numpy image shape {1}." . format ( transformation_matrix . shape , np_img . shape ) ) if mean_vector . shape [ 0 ] != transformation_matrix . shape [ 0 ] : raise ValueError ( "mean_vector length {0} should match either one dimension of the square " "transformation_matrix {1}." . format ( mean_vector . shape [ 0 ] , transformation_matrix . shape ) ) zero_centered_img = np_img . reshape ( 1 , - 1 ) - mean_vector transformed_img = np . dot ( zero_centered_img , transformation_matrix ) if transformed_img . size != np_img . size : raise ValueError ( "Linear transform failed, input shape should match with transformation_matrix." ) transformed_img = transformed_img . reshape ( np_img . shape ) return transformed_img