<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def load_model( self, the_metamodel, filename, is_main_model, encoding='utf-8', add_to_local_models=True):
 """ load a single model Args: the_metamodel: the metamodel used to load the model filename: the model to be loaded (if not cached) Returns: the loaded/cached model """


        if not self.local_models.has_model(filename):
            if self.all_models.has_model(filename):
                new_model = self.all_models.filename_to_model[filename]
            else:
                # print("LOADING {}".format(filename))
                # all models loaded here get their references resolved from the
                # root model
                new_model = the_metamodel.internal_model_from_file(
                    filename, pre_ref_resolution_callback=lambda
                    other_model: self.pre_ref_resolution_callback(other_model),
                    is_main_model=is_main_model, encoding=encoding)
                self.all_models.filename_to_model[filename] = new_model
            # print("ADDING {}".format(filename))
            if add_to_local_models:
                self.local_models.filename_to_model[filename] = new_model
        assert self.all_models.has_model(filename)  # to be sure...
        return self.all_models.filename_to_model[filename]