def _local_grad(self, parent, d_out_d_self):
        parent_shape = self._parents[parent].shape
        num_singletons = len(d_out_d_self.shape) - len(parent_shape)
        if num_singletons > 0:
            extra_singletons = tuple(range(num_singletons))
            result = np.sum(d_out_d_self, axis=extra_singletons, keepdims=False)
        else:
            result = d_out_d_self

        assert len(result.shape) == len(parent_shape)
        original_singletons = tuple(np.where(np.array(parent_shape) == 1)[0])
        return np.sum(result, axis=original_singletons, keepdims=True)
dataset/ETHPy150Open HIPS/Kayak/kayak/matrix_ops.py/MatAdd._local_grad/original