class_docstr: Inherits time series methods from TSM class.
  
  **** NON-GAUSSIAN DYNAMIC REGRESSION MODELS ****
  
  Parameters
  ----------
  
  formula : string
      patsy string describing the regression
  
  data : pd.DataFrame
      Field to specify the data that will be used
  
  family : 
      e.g. pf.Normal(0,1)
docstr: Performs Black Box Variational Inference
  
  Parameters
  ----------
  posterior : method
      Hands bbvi_fit a posterior object
  
  optimizer : string
      Stochastic optimizer: either RMSProp or ADAM.
  
  iterations: int
      How many iterations to run
  
  print_progress : bool
      Whether tp print the ELBO progress or not
  
  start_diffuse : bool
      Whether to start from diffuse values (if not: use approx Gaussian)
  
  Returns
  ----------
  BBVIResults object
docstr_tok: ["Performs","Black","Box","Variational","Inference","Parameters","--","--","--","--","--","posterior",":","method","Hands","bbvi_fit","a","posterior","object","optimizer",":","string","Stochastic","optimizer",":","either","RMSProp","or","ADAM",".","iterations",":","int","How","many","iterations","to","run","print_progress",":","bool","Whether","tp","print","the","ELBO","progress","or","not","start_diffuse",":","bool","Whether","to","start","from","diffuse","values","(","if","not",":","use","approx","Gaussian",")","Returns","--","--","--","--","--","BBVIResults","object"]
code: def _bbvi_fit(
      self,
      optimizer="RMSProp",
      iterations=1000,
      print_progress=True,
      start_diffuse=False,
      **kwargs,
  ):
      """Performs Black Box Variational Inference
  
      Parameters
      ----------
      posterior : method
          Hands bbvi_fit a posterior object
  
      optimizer : string
          Stochastic optimizer: either RMSProp or ADAM.
  
      iterations: int
          How many iterations to run
  
      print_progress : bool
          Whether tp print the ELBO progress or not
  
      start_diffuse : bool
          Whether to start from diffuse values (if not: use approx Gaussian)
  
      Returns
      ----------
      BBVIResults object
      """
      if self.model_name2 in ["t", "Skewt"]:
          default_learning_rate = 0.0001
      else:
          default_learning_rate = 0.001
  
      batch_size = kwargs.get("batch_size", 24)
      learning_rate = kwargs.get("learning_rate", default_learning_rate)
      record_elbo = kwargs.get("record_elbo", False)
  
      # Starting values
      gaussian_latents = (
          self._preoptimize_model()
      )  # find parameters for Gaussian model
  
      phi = self.latent_variables.get_z_starting_values()
      q_list = self.initialize_approx_dist(
          phi, start_diffuse, gaussian_latents
      )
  
      # PERFORM BBVI
      bbvi_obj = ifr.CBBVI(
          self.neg_logposterior,
          self.log_p_blanket,
          q_list,
          batch_size,
          optimizer,
          iterations,
          learning_rate,
          record_elbo,
      )
  
      if print_progress is False:
          bbvi_obj.printer = False
  
      q, q_params, q_ses, elbo_records = bbvi_obj.run()
  
      self.latent_variables.set_z_values(
          q_params[: self.z_no],
          "BBVI",
          np.exp(q_ses[: self.z_no]),
          None,
      )
  
      # STORE RESULTS
      for k in range(len(self.latent_variables.z_list)):
          self.latent_variables.z_list[k].q = q[k]
  
      # Theta values and states
      states = q_params[self.z_no : self.z_no + self.data.shape[0]]
      states_var = np.exp(
          q_ses[self.z_no : self.z_no + self.data.shape[0]]
      )
  
      for state_i in range(1, self.state_no):
          states = np.vstack(
              (
                  states,
                  q_params[
                      (self.z_no + (self.data.shape[0] * state_i)) : (
                          self.z_no
                          + (self.data.shape[0] * (state_i + 1))
                      )
                  ],
              )
          )
          states_var = np.vstack(
              (
                  states_var,
                  np.exp(
                      q_ses[
                          (
                              self.z_no + (self.data.shape[0] * state_i)
                          ) : (
                              self.z_no
                              + (self.data.shape[0] * (state_i + 1))
                          )
                      ]
                  ),
              )
          )
  
      if self.state_no == 1:
          states = np.array([states])
          states_var = np.array([states_var])
  
      theta = np.sum(self.X * states.T, axis=1)
      Y = self.data
      scores = None
      X_names = self.X_names
      self.states = states
      self.states_var = states_var
  
      return res.BBVISSResults(
          data_name=self.data_name,
          X_names=X_names,
          model_name=self.model_name,
          model_type=self.model_type,
          latent_variables=self.latent_variables,
          data=Y,
          index=self.index,
          multivariate_model=self.multivariate_model,
          objective=self.neg_logposterior(q_params),
          method="BBVI",
          ses=q_ses[: self.z_no],
          signal=theta,
          scores=scores,
          elbo_records=elbo_records,
          z_hide=self._z_hide,
          max_lag=self.max_lag,
          states=states,
          states_var=states_var,
      )
  
imports: import sys
  import numpy
  import pandas
  import scipy.stats
  from scipy import optimize
  from ..None import inference
  from ..None import families
  from ..None import output
  from ..None import tsm
  from ..None import data_check
  from ..None import covariances
  from ..None import results
  from ..None import gas
  from .kalman import *
  from .dynlin import *
label_desc: Use image node_id 18 for calling the NDynReg obj's underlying member method code with example usage: obj._bbvi_fit(optimizer, iterations, print_progress, start_diffuse) and returns: res