          logger.debug("Initializing %s: (model_dir: '%s', model_name: '%s', "
                       "config_changeable_items: '%s', no_logs: %s, pingpong: %s, "
                       "training_image_size: '%s'", self.__class__.__name__, model_dir, model_name,
                       config_changeable_items, no_logs, pingpong, training_image_size)
          self.serializer = Serializer.get_serializer("json")
          filename = "{}_state.{}".format(model_name, self.serializer.ext)
          self.filename = str(model_dir / filename)
          self.name = model_name
          self.iterations = 0
          self.session_iterations = 0
          self.training_size = training_image_size
 
</s> remove         self.serializer = JSONSerializer
 </s> add         self.serializer = get_serializer("json") </s> remove         self.serializer = Serializer.get_serializer("json")
 </s> add         self.serializer = get_serializer("json") </s> remove             logger.debug("Serializer set from file extension: '%s'", extension)
            retval = Serializer.get_serializer_from_ext(extension)
 </s> add             logger.debug("Serializer set from filename extension: '%s'", extension)
            retval = get_serializer_from_filename(filename) </s> remove         try:
            with open(self.filename, "rb") as inp:
                state = self.serializer.unmarshal(inp.read().decode("utf-8"))
                self.name = state.get("name", self.name)
                self.sessions = state.get("sessions", dict())
                self.lowest_avg_loss = state.get("lowest_avg_loss", dict())
                self.iterations = state.get("iterations", 0)
                self.training_size = state.get("training_size", 256)
                self.inputs = state.get("inputs", dict())
                self.config = state.get("config", dict())
                logger.debug("Loaded state: %s", state)
                self.replace_config(config_changeable_items)
        except IOError as err:
            logger.warning("No existing state file found. Generating.")
            logger.debug("IOError: %s", str(err))
        except JSONDecodeError as err:
            logger.debug("JSONDecodeError: %s:", str(err))
 </s> add         if not os.path.exists(self.filename):
            logger.info("No existing state file found. Generating.")
            return
        state = self.serializer.load(self.filename)
        self.name = state.get("name", self.name)
        self.sessions = state.get("sessions", dict())
        self.lowest_avg_loss = state.get("lowest_avg_loss", dict())
        self.iterations = state.get("iterations", 0)
        self.training_size = state.get("training_size", 256)
        self.inputs = state.get("inputs", dict())
        self.config = state.get("config", dict())
        logger.debug("Loaded state: %s", state)
        self.replace_config(config_changeable_items) </s> remove         self.file = "{}.{}".format(filename, self.serializer.ext)
 </s> add         self.file = "{}.{}".format(filename, self.serializer.file_extension)
        self.serializer = get_serializer("json")
        filename = "{}_state.{}".format(model_name, self.serializer.file_extension)
          logger.debug("Initializing %s: (model_dir: '%s', model_name: '%s', "
                       "config_changeable_items: '%s', no_logs: %s, pingpong: %s, "
                       "training_image_size: '%s'", self.__class__.__name__, model_dir, model_name,
                       config_changeable_items, no_logs, pingpong, training_image_size)
        self.serializer = get_serializer("json")
        filename = "{}_state.{}".format(model_name, self.serializer.file_extension)
        self.serializer = get_serializer("json")
        filename = "{}_state.{}".format(model_name, self.serializer.file_extension)
          self.filename = str(model_dir / filename)
          self.name = model_name
          self.iterations = 0
          self.session_iterations = 0
          self.training_size = training_image_size
keep keep keep keep replace replace keep keep keep keep keep
 Standardize serialization (#903)

* Standardize serialization

- Linting
- Standardize serializer use throughout code
- Extend serializer to load and save files
- Always load and save in utf-8
- Create documentation 
plugins/train/model/_base.py