code: def try_fix_dataset(dataset):
      
      if isinstance(dataset, numpy.ndarray):
          if len(dataset.shape) == 3:  # NumPy 3D
              if dataset.shape[-1] == 3:
                  return dataset.transpose((2, 0, 1))
          elif len(dataset.shape) == 4:  # NumPy 4D
              if dataset.shape[-1] == 3:
                  return dataset.transpose((0, 3, 1, 2))
          # Otherwise couldn't fix it.
          return dataset
      # List of Numpy 3D arrays.
      for i, d in enumerate(dataset):
          if not isinstance(d, numpy.ndarray):
              return dataset
          if not (len(d.shape) == 3 and d.shape[-1] == 3):
              return dataset
          dataset[i] = d.transpose()
      return dataset
docs: Transpose the image data if it's in PIL format.