<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _init_caches(self):
 from collections import defaultdict from .cache import Cache, NodesCache, EdgesCache self._where_cached = defaultdict(list) self._global_cache = self.query._global_cache = {} self._node_objs = node_objs = WeakValueDictionary() self._get_node_stuff = (node_objs, self._node_exists, self._make_node) self._edge_objs = edge_objs = WeakValueDictionary() self._get_edge_stuff = (edge_objs, self._edge_exists, self._make_edge) for k, v in self.query.global_items():
 if k == 'branch': self._obranch = v elif k == 'turn': self._oturn = int(v) elif k == 'tick': self._otick = int(v) else: self._global_cache[k] = v self._childbranch = defaultdict(set) """Immediate children of a branch"""

        self._branches = {}
        """Start time, end time, and parent of each branch"""
        self._branch_parents = defaultdict(set)
        """Parents of a branch at any remove"""
        self._turn_end = defaultdict(lambda: 0)
        """Tick on which a (branch, turn) ends"""
        self._turn_end_plan = defaultdict(lambda: 0)
        """Tick on which a (branch, turn) ends, even if it hasn't been simulated"""
        self._graph_objs = {}
        self._plans = {}
        self._branches_plans = defaultdict(set)
        self._plan_ticks = defaultdict(lambda: defaultdict(list))
        self._time_plan = {}
        self._plans_uncommitted = []
        self._plan_ticks_uncommitted = []
        self._graph_val_cache = Cache(self)
        self._graph_val_cache.setdb = self.query.graph_val_set
        self._graph_val_cache.deldb = self.query.graph_val_del_time
        self._nodes_cache = NodesCache(self)
        self._nodes_cache.setdb = self.query.exist_node
        self._nodes_cache.deldb = self.query.nodes_del_time
        self._edges_cache = EdgesCache(self)
        self._edges_cache.setdb = self.query.exist_edge
        self._edges_cache.deldb = self.query.edges_del_time
        self._node_val_cache = Cache(self)
        self._node_val_cache.setdb = self.query.node_val_set
        self._node_val_cache.deldb = self.query.node_val_del_time
        self._edge_val_cache = Cache(self)
        self._edge_val_cache.setdb = self.query.edge_val_set
        self._edge_val_cache.deldb = self.query.edge_val_del_time