<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_z(self, name, prior, q, index=True):
 """ Adds latent variable Parameters name : str Name of the latent variable prior : Prior object Which prior distribution? E.g. Normal(0,1) q : Distribution object Which distribution to use for variational approximation index : boolean Whether to index the variable in the z_indices dictionary Returns None (changes priors in LatentVariables object) """


        self.z_list.append(LatentVariable(name,len(self.z_list),prior,q))
        if index is True:
            self.z_indices[name] = {'start': len(self.z_list)-1, 'end': len(self.z_list)-1}