def load(self, requirements_file=None):
        """Load or reload requirements from a requirements.txt file.

        :param requirements_file: if not given, the filename used from
            initialization will be read again.
        """
        if requirements_file is None:
            requirements_file = self.filename
            if requirements_file is None:
                raise ValueError("no filename provided")
        elif isinstance(requirements_file, text_type):
            requirements_file = Path(requirements_file)
        self.clear()
        with requirements_file.open() as f:
            self.loads(f.read())

        if isinstance(requirements_file, (text_type, Path)):
            self.filename = requirements_file
def add_handles(self, model, forward_handle, backward_handle):
        """
        Add handles to all non-container layers in the model.
        Recursively for non-container layers
        """
        handles_list = []
        model_children = list(model.children())
        if model_children:
            for child in model_children:
                handles_list.extend(self.add_handles(child, forward_handle, backward_handle))
        else:  # leaves
            handles_list.append(model.register_forward_hook(forward_handle))
            handles_list.append(model.register_backward_hook(backward_handle))
        return handles_list