You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: local_tangent_space_alignment.rb
    path of file: ./repos/rumale/rumale-manifold/lib/rumale/manifold
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

require 'rumale/base/estimator'
require 'rumale/base/transformer'
require 'rumale/pairwise_metric'
require 'rumale/validation'

module Rumale
  module Manifold
    # LocalTangentSpaceAlignment is a class that implements Local Tangent Space Alignment.
    #
    # @example
    #   require 'numo/linalg/autoloader'
    #   require 'rumale/manifold/local_tangent_space_alignment'
    #
    #   lem = Rumale::Manifold::LocalTangentSpaceAlignment.new(n_components: 2, n_neighbors: 15)
    #   z = lem.fit_transform(x)
    #
    # *Reference*
    # - Zhang, A., and Zha, H., "Principal Manifolds and Nonlinear Diemnsion Reduction via Local Tangent Space Alignment," SIAM Journal on Scientific Computing, vol. 26, iss. 1, pp. 313-338, 2004.
    class
    
      def transform(x)
        x = Rumale::Validation.check_convert_sample_array(x)

        n_samples = x.shape[0]
        tol = @params[:reg_param].fdiv(@params[:n_neighbors])
        distance_mat = Rumale::PairwiseMetric.squared_error(x, @x_train)
        neighbor_ids = neighbor_ids(distance_mat, @params[:n_neighbors], false)
        weight_mat = Numo::DFloat.zeros(n_samples, @x_train.shape[0])

        n_samples.times do |n|
          x_local = @x_train[neighbor_ids[n, true], true] - x[n, true]
          gram_mat = x_local.dot(x_local.transpose)
          gram_mat += tol * weight_mat.trace * Numo::DFloat.eye(@params[:n_neighbors])
          weights = Numo::Linalg.solve(gram_mat, Numo::DFloat.ones(@params[:n_neighbors]))
          weights /= weights.sum + 1e-8
          weight_mat[n, neighbor_ids[n, true]] = weights
        end

        weight_mat.dot(@embedding)
      end