code: def weighted_mse(y_true, y_pred):
      scaling_factor = 2.0  # This can be tuned
  
      # Flatten y_true to 1D and sort the values
      values = tf.sort(tf.reshape(y_true, [-1]), axis=-1)
  
      # Calculate the index for the 75th percentile
      index = tf.cast(
          tf.round(0.75 * (tf.cast(tf.size(values), tf.float32) - 1)),
          tf.int32,
      )
  
      # Select the value at the 75th percentile
      threshold = tf.gather(values, index)
  
      # Compute weights based on the threshold
      weights = tf.where(y_true > threshold, scaling_factor, 1.0)
  
      # Calculate weighted MSE
      weighted_squared_error = tf.multiply(
          weights, tf.square(y_true - y_pred)
      )
  
      # Return the mean loss
      return tf.reduce_mean(weighted_squared_error)
  
imports: import copy
  import numpy
  import pandas
  import matplotlib.pyplot
  from sklearn.metrics import mean_squared_error
  from sklearn.ensemble import RandomForestClassifier, RandomForestRegressor
  from tensorflow.keras.callbacks import LearningRateScheduler, ReduceLROnPlateau
  from tensorflow.keras.callbacks import EarlyStopping, ModelCheckpoint
  from tensorflow.keras.utils import to_categorical
  import pdb
  from sklearn.metrics import accuracy_score, balanced_accuracy_score, average_precision_score, f1_score, mean_squared_error
  from sklearn.utils import shuffle
  import numpy
  from sklearn.utils import shuffle
  import copy
  from tensorflow.keras.callbacks import ReduceLROnPlateau
  import matplotlib.pyplot
  import tensorflow
  from collections import OrderedDict
  from collections import Counter
  from sklearn.utils.class_weight import compute_class_weight
  import copy
  from tensorflow.keras.callbacks import EarlyStopping, ModelCheckpoint, Callback
  from sklearn.base import BaseEstimator, TransformerMixin
  from tensorflow.keras.optimizers import Adam
  from tensorflow.keras.layers import Dense, Dropout, BatchNormalization, Activation
  from tensorflow.keras.models import Sequential, Model
  from tensorflow.keras.regularizers import l1_l2
  from tensorflow.keras.callbacks import EarlyStopping, ModelCheckpoint, LearningRateScheduler
  from sklearn.metrics import balanced_accuracy_score, classification_report
  import numpy
  import tensorflow
  from tensorflow.keras.layers import Input, Dense, BatchNormalization, Activation, Dropout
  from tensorflow.keras.models import Sequential
  from tensorflow.keras.regularizers import l1_l2
  from tensorflow.keras.metrics import Metric
  import time
label_desc: Use image node_id 6 for calling a global function with example usage: weighted_mse(y_true, y_pred) and returns: tf