docstr: Starts the optimization
  
  The main multi-scale symmetric optimization algorithm
code: def _optimize(self):
      """Starts the optimization
  
      The main multi-scale symmetric optimization algorithm
      """
      self.full_energy_profile = []
      if self.callback is not None:
          self.callback(self, RegistrationStages.OPT_START)
      for level in range(self.levels - 1, -1, -1):
          if self.verbosity >= VerbosityLevels.STATUS:
              logger.info("Optimizing level %d" % level)
  
          self.current_level = level
  
          self.metric.set_levels_below(self.levels - level)
          self.metric.set_levels_above(level)
  
          if level < self.levels - 1:
              expand_factors = self.static_ss.get_expand_factors(
                  level + 1, level
              )
              new_shape = self.static_ss.get_domain_shape(level)
              self.static_to_ref.expand_fields(
                  expand_factors, new_shape
              )
              self.moving_to_ref.expand_fields(
                  expand_factors, new_shape
              )
  
          self.niter = 0
          self.energy_list = []
          derivative = np.inf
  
          if self.callback is not None:
              self.callback(self, RegistrationStages.SCALE_START)
  
          while (
              self.niter < self.level_iters[self.levels - 1 - level]
          ) and (self.opt_tol < derivative):
              derivative = self._iterate()
              self.niter += 1
  
          self.full_energy_profile.extend(self.energy_list)
  
          if self.callback is not None:
              self.callback(self, RegistrationStages.SCALE_END)
  
      # Reporting mean and std in stats[1] and stats[2]
      residual, stats = self.static_to_ref.compute_inversion_error()
  
      if self.verbosity >= VerbosityLevels.DIAGNOSE:
          logger.info(
              "Static-Reference Residual error: %0.6f (%0.6f)"
              % (stats[1], stats[2])
          )
  
      residual, stats = self.moving_to_ref.compute_inversion_error()
  
      if self.verbosity >= VerbosityLevels.DIAGNOSE:
          logger.info(
              "Moving-Reference Residual error :%0.6f (%0.6f)"
              % (stats[1], stats[2])
          )
  
      # Compose the two partial transformations
      self.static_to_ref = self.moving_to_ref.warp_endomorphism(
          self.static_to_ref.inverse()
      ).inverse()
  
      # Report mean and std for the composed deformation field
      residual, stats = self.static_to_ref.compute_inversion_error()
      if self.verbosity >= VerbosityLevels.DIAGNOSE:
          logger.info(
              "Final residual error: %0.6f (%0.6f)"
              % (stats[1], stats[2])
          )
      if self.callback is not None:
          self.callback(self, RegistrationStages.OPT_END)
  
imports: import logging
  import abc
  import numpy
  import numpy.linalg
  import nibabel
  from nibabel.streamlines import ArraySequence
  from dipy.align import vector_fields
  from dipy.align import floating
  from dipy.align import VerbosityLevels
  from dipy.align import Bunch
  from dipy.align.scalespace import ScaleSpace
label_desc: Use image node_id 12 for calling the SymmetricDiffeomorphicRegistration obj's underlying member method code with example usage: obj._optimize() without return types