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: OSTD.m
    path of file: ./repos/lrslibrary/algorithms/td/OSTD
    
    the code of the file until where you have to start completion: %{
Online Stochastic Tensor Decomposition for Background Subtraction

Author: Andrews Sobral
https://github.com/andrewssobral/ostd

Reference:
@inproceedings{ostd,
author    = {Sobral, Andrews and Javed, Sajid and Ki Jung, Soon and Bouwmans, Thierry and Zahzah, El-hadi},
title     = {Online Tensor Decomposition for Background Subtraction in Multispectral Video Sequences},
booktitle = {IEEE International Conference on Computer Vision Workshops (ICCVW)},
address   = {Santiago, Chile},
year      = {2015},
month     = {December},
url       = {https://github.com/andrewssobral/ostd}
}
%}
function [Tlowrank,Tsparse,Tmask,Tm] = OSTD(T,k,Tm)
  Tlowrank = zeros(size(T));
  
    
function [Tlowrank,Tsparse,Tmask,Tm] = OSTD(T,k,Tm)
  Tlowrank = zeros(size(T));
  Tsparse = zeros(size(T));
  nmode = length(size(T));
  for j = 1:nmode
    %disp(['tensor.mode-' num2str(j)]);
    Titm = tenmat(T,j); M = double(Titm); % imagesc(Ti)
    z = M(:); %disp(size(z))
    lambda1 = (1/sqrt(max(size(z))));
    lambda2 = lambda1*10;
    if(k == 1)
      [ndim,~] = size(z);
      nrank = 10;
      Tm{j}.A = zeros(nrank,nrank);
      Tm{j}.B = zeros(ndim,nrank);
      
      %%% Initialization by Random Basis
      %Tm{j}.L = rand(ndim,nrank);
      
      %%% Initialization by Bilateral Random Projections
      power = 1;
      Y2 = randn(size(z,2),nrank);
      for jj = 1:power+1
        Y1 = z*Y2;
        Y2 = z'*Y1;
      end