code: def test_online_transform(self):
      corpus = list(self.corpus)
      doc = corpus[0]  # use the corpus' first document for testing
  
      # create the transformation model
      model2 = lsimodel.LsiModel(
          corpus=corpus, num_topics=5
      )  # compute everything at once
      # start with no documents, we will add them later
      model = lsimodel.LsiModel(
          corpus=None, id2word=model2.id2word, num_topics=5
      )
  
      # train model on a single document
      model.add_documents([corpus[0]])
  
      # transform the testing document with this partial transformation
      transformed = model[doc]
      vec = matutils.sparse2full(
          transformed, model.num_topics
      )  # convert to dense vector, for easier equality tests
      expected = np.array(
          [-1.73205078, 0.0, 0.0, 0.0, 0.0]
      )  # scaled LSI version
      self.assertTrue(
          np.allclose(abs(vec), abs(expected), atol=1e-6)
      )  # transformed entries must be equal up to sign
  
      # train on another 4 documents
      model.add_documents(
          corpus[1:5], chunksize=2
      )  # train on 4 extra docs, in chunks of 2 documents, for the lols
  
      # transform a document with this partial transformation
      transformed = model[doc]
      vec = matutils.sparse2full(
          transformed, model.num_topics
      )  # convert to dense vector, for easier equality tests
      expected = np.array(
          [
              -0.66493785,
              -0.28314203,
              -1.56376302,
              0.05488682,
              0.17123269,
          ]
      )  # scaled LSI version
      self.assertTrue(
          np.allclose(abs(vec), abs(expected), atol=1e-6)
      )  # transformed entries must be equal up to sign
  
      # train on the rest of documents
      model.add_documents(corpus[5:])
  
      # make sure the final transformation is the same as if we had decomposed the whole corpus at once
      vec1 = matutils.sparse2full(model[doc], model.num_topics)
      vec2 = matutils.sparse2full(model2[doc], model2.num_topics)
      # the two LSI representations must equal up to sign
      self.assertTrue(np.allclose(abs(vec1), abs(vec2), atol=1e-5))
  
imports: import logging
  import unittest
  import numpy
  import scipy.linalg
  from gensim import matutils
  from gensim.corpora.mmcorpus import MmCorpus
  from gensim.models import lsimodel
  from gensim.test import basetmtests
  from gensim.test.utils import datapath, get_tmpfile
label_desc: Use image node_id 5 for calling the TestLsiModel obj's underlying member method code with example usage: obj.test_online_transform() without return types