  import tensorflow as tf
  from tensorflow.python.framework import errors_impl as tf_errors
  from tqdm import tqdm
  
  from lib.align import (Alignments, AlignedFace, DetectedFace, get_centered_size,
                         update_legacy_png_header)
  from lib.image import read_image_meta_batch
  from lib.training_data import TrainingDataGenerator
  from lib.utils import FaceswapError, get_backend, get_folder, get_image_paths
  from plugins.train._config import Config
  
  logger = logging.getLogger(__name__)  # pylint: disable=invalid-name
  
 
</s> remove from tqdm import tqdm
 </s> add  </s> remove from concurrent import futures
from functools import partial

 </s> add  </s> remove def read_image_batch(filenames):
 </s> add def read_image_batch(filenames, with_metadata=False): </s> remove     def _get_alignments_data(self):
        """ Extrapolate alignments and masks from the alignments file into a `dict` for the
        training data generator.

        Removes any images from :attr:`_images` if they do not have alignment data attached.

        Returns
        -------
        dict:
            Includes the key `aligned_faces` holding aligned face information and the key
            `versions` indicating the alignments file versions that the faces have come from.
            In addition, the following optional keys are provided: `masks` if masks are required
            for training, `masks_eye` if eye masks are required and `masks_mouth` if mouth masks
            are required. """
        penalized_loss = self._model.config["penalized_mask_loss"]

        alignments = _TrainingAlignments(self._model, self._images)
        # Update centering if it has been changed by legacy face sets in TrainingAlignments
        self._config["centering"] = self._model.config["centering"]
        retval = dict(aligned_faces=alignments.aligned_faces,
                      versions=alignments.versions)

        if self._model.config["learn_mask"] or penalized_loss:
            logger.debug("Adding masks to training opts dict")
            retval["masks"] = alignments.masks

        if penalized_loss and self._model.config["eye_multiplier"] > 1:
            retval["masks_eye"] = alignments.masks_eye

        if penalized_loss and self._model.config["mouth_multiplier"] > 1:
            retval["masks_mouth"] = alignments.masks_mouth

        logger.debug({key: {k: v if isinstance(v, float) else len(v)
                            for k, v in val.items()}
                      for key, val in retval.items()})

        # Replace _images with list containing valid alignment data
        for side, aligned_faces in alignments.aligned_faces.items():
            if len(aligned_faces) != len(self._images[side]):
                logger.info("Updating training images list with images containing valid metadata "
                            "for side '%s'", side.upper())
                self._images[side] = list(aligned_faces.keys())
        return retval

 </s> add 
from lib.training import TrainingDataGenerator
  import tensorflow as tf
  from tensorflow.python.framework import errors_impl as tf_errors
  from tqdm import tqdm
  
from lib.training import TrainingDataGenerator
from lib.training import TrainingDataGenerator
from lib.training import TrainingDataGenerator
from lib.training import TrainingDataGenerator
  from lib.utils import FaceswapError, get_backend, get_folder, get_image_paths
  from plugins.train._config import Config
  
  logger = logging.getLogger(__name__)  # pylint: disable=invalid-name
  
keep keep keep keep replace replace replace replace keep keep keep keep keep
 Training startup updates
  - Remove alignments path option from cli
  - Restructure training_data.py
  - Load alignment data from PNG header during first epoch
  - lib.image.read_image_batch - Add option to return metadata
  - lib.utils.get_image_paths - Add option for explicit extension
  - plugins.train.trainer._base - remove pre-cache alignments code
  - scripts.train - Check first image in training folders for metadata
  - Documentation 
plugins/train/trainer/_base.py