import torch


def load_checkpoint(checkpoint_path):
	"""Return a model from a checkpoint
	
	Args:
		checkpoint_path (str): A path to a valid PyTorch checkpoint file.

	Returns:
		tuple: Return a tuple of the following
			``checkpoint_path`` - A path to a valid PyTorch checkpoint file
			``model`` - A valid ``torch.Module`` object
			``model._get_name()`` - Name of the model
			``class_to_idx`` - Class to id mapping of the train data

	"""
	
	checkpoint = torch.load(checkpoint_path, map_location=lambda storage, loc: storage)
	model = checkpoint['base_model']
	
	try:
		model.fc = checkpoint['classifier']
	except:
		model.classifier = checkpoint['classifier']
		
	model.load_state_dict(checkpoint['state_dict'], strict=False)
	class_to_idx = checkpoint['class_to_idx']
	
	return checkpoint_path, model, model._get_name(), class_to_idx