code: def flatten_extra_dim(data: Optional[np.array]) -> Optional[np.array]:
      """
      Removes last dimension if it is equal to one
  
      :param data: ndarray to be reshaped
  
      :return: reshaped view of the original array or None if input is None
      """
  
      if data is not None and data.shape[-1] == 1:
          return np.squeeze(data, axis=-1)
      return data
  
imports: from functools import reduce
  from typing import Optional
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: flatten_extra_dim(data) and returns: data, np