docstr: Starts the optimization
  
  Parameters
  ----------
  static : array, shape (S, R, C) or (R, C)
      the image to be used as reference during optimization. The
      displacement fields will have the same discretization as the static
      image.
  moving : array, shape (S, R, C) or (R, C)
      the image to be used as "moving" during optimization. Since the
      deformation fields' discretization is the same as the static image,
      it is necessary to pre-align the moving image to ensure its domain
      lies inside the domain of the deformation fields. This is assumed
      to be accomplished by "pre-aligning" the moving image towards the
      static using an affine transformation given by the 'prealign'
      matrix
  static_grid2world : array, shape (dim+1, dim+1)
      the voxel-to-space transformation associated to the static image
  moving_grid2world : array, shape (dim+1, dim+1)
      the voxel-to-space transformation associated to the moving image
  prealign : array, shape (dim+1, dim+1)
      the affine transformation (operating on the physical space)
      pre-aligning the moving image towards the static
  
  Returns
  -------
  static_to_ref : DiffeomorphicMap object
      the diffeomorphic map that brings the moving image towards the
      static one in the forward direction (i.e. by calling
      static_to_ref.transform) and the static image towards the
      moving one in the backward direction (i.e. by calling
      static_to_ref.transform_inverse).
code: def optimize(
      self,
      static,
      moving,
      static_grid2world=None,
      moving_grid2world=None,
      prealign=None,
  ):
      """
      Starts the optimization
  
      Parameters
      ----------
      static : array, shape (S, R, C) or (R, C)
          the image to be used as reference during optimization. The
          displacement fields will have the same discretization as the static
          image.
      moving : array, shape (S, R, C) or (R, C)
          the image to be used as "moving" during optimization. Since the
          deformation fields' discretization is the same as the static image,
          it is necessary to pre-align the moving image to ensure its domain
          lies inside the domain of the deformation fields. This is assumed
          to be accomplished by "pre-aligning" the moving image towards the
          static using an affine transformation given by the 'prealign'
          matrix
      static_grid2world : array, shape (dim+1, dim+1)
          the voxel-to-space transformation associated to the static image
      moving_grid2world : array, shape (dim+1, dim+1)
          the voxel-to-space transformation associated to the moving image
      prealign : array, shape (dim+1, dim+1)
          the affine transformation (operating on the physical space)
          pre-aligning the moving image towards the static
  
      Returns
      -------
      static_to_ref : DiffeomorphicMap object
          the diffeomorphic map that brings the moving image towards the
          static one in the forward direction (i.e. by calling
          static_to_ref.transform) and the static image towards the
          moving one in the backward direction (i.e. by calling
          static_to_ref.transform_inverse).
  
      """
      if self.verbosity >= VerbosityLevels.DEBUG:
          if prealign is not None:
              logger.info("Pre-align: " + str(prealign))
  
      self._init_optimizer(
          static.astype(floating),
          moving.astype(floating),
          static_grid2world,
          moving_grid2world,
          prealign,
      )
      self._optimize()
      self._end_optimizer()
      self.static_to_ref.forward = np.array(self.static_to_ref.forward)
      self.static_to_ref.backward = np.array(
          self.static_to_ref.backward
      )
      return self.static_to_ref
  
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 13 for calling the SymmetricDiffeomorphicRegistration obj's underlying member method code with example usage: obj.optimize(static, moving, static_grid2world, moving_grid2world, prealign) and returns: self