code: def squeeze_to_same_rank(x1, x2):
      """Squeeze last dim if ranks differ from expected by exactly 1."""
      x1_rank = len(x1.shape)
      x2_rank = len(x2.shape)
      if x1_rank == x2_rank:
          return x1, x2
      if x1_rank == x2_rank + 1:
          if x1.shape[-1] == 1:
              x1 = ops.squeeze(x1, axis=-1)
      if x2_rank == x1_rank + 1:
          if x2.shape[-1] == 1:
              x2 = ops.squeeze(x2, axis=-1)
      return x1, x2
  
file_path: keras/keras/losses/loss.py
imports: import tree
  from keras import backend
  from keras import ops
  from keras.api_export import keras_export
  from keras.utils.naming import auto_name
label_desc: Use image node_id 2 for calling a global function with example usage: squeeze_to_same_rank(x1, x2) and returns: x1,  x2, x1,  x2