<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _update_weight(self, data, R, n_local_subj, local_weight_offset):
 """update local weight Parameters data : list of 2D array, element i has shape=[n_voxel, n_tr] Subjects' fMRI data. R : list of 2D arrays, element i has shape=[n_voxel, n_dim] Each element in the list contains the scanner coordinate matrix of fMRI data of one subject. n_local_subj : integer Number of subjects allocated to this process. local_weight_offset : 1D array Offset of each subject's weights on this process. Returns ------- HTFA Returns the instance itself. """

        for s, subj_data in enumerate(data):
            base = s * self.prior_size
            centers = self.local_posterior_[base:base + self.K * self.n_dim]\
                .reshape((self.K, self.n_dim))
            start_idx = base + self.K * self.n_dim
            end_idx = base + self.prior_size
            widths = self.local_posterior_[start_idx:end_idx]\
                .reshape((self.K, 1))
            unique_R, inds = self.get_unique_R(R[s])
            F = self.get_factors(unique_R, inds, centers, widths)
            start_idx = local_weight_offset[s]
            if s == n_local_subj - 1:
                self.local_weights_[start_idx:] =\
                    self.get_weights(subj_data, F).ravel()
            else:
                end_idx = local_weight_offset[s + 1]
                self.local_weights_[start_idx:end_idx] =\
                    self.get_weights(subj_data, F).ravel()
        return self