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: ttm_me_mem.m
    path of file: ./repos/encode/external/tensor_toolbox_2.5/met
    
    the code of the file until where you have to start completion: function [max_mem] = ttm_me_mem(X, U, edims, sdims, tflag)
%TTM_ME_MEM Estimates intermediate memory comsumption for ttm_me.
%
%  MAX_MEM = TTM_ME_MEM(X, U, EDIMS, SDIMS, TFLAG) estimates the memory
%  comsumption used in the TTM_ME function. Here, X is a sparse tensor  
%  (sptensor), U is a cell array of matrices of length ndims(X),
%  EDIMS specifies the dimensions that are to be handled elementwise, sdims
%  specifies those dimensions that are to be handled in the standard way,
%  and TFLAG indicates to multiply the matrix transpose.
%
%   See also TENSOR_TOOLBOX, TUCKER_ME, TTM_ME.
%
%   Code by Tamara Kolda and Jimeng Sun, 2008. 
%
%   Based on the paper:
%   T. G. Kolda and J. Sun. Scalable Tensor Decompositions for Multi-aspect
%   Data Mining. In: ICDM 2008: Proceedings of the 8th IEEE International
%   Conference on Data Mining, December 2008.  

% $Id: ttm_me_mem.m,v 1.2 2009/07/08 00:03:52 tgkolda Exp $


    
function [max_mem] = ttm_me_mem(X, U, edims, sdims, tflag)
%TTM_ME_MEM Estimates intermediate memory comsumption for ttm_me.
%
%  MAX_MEM = TTM_ME_MEM(X, U, EDIMS, SDIMS, TFLAG) estimates the memory
%  comsumption used in the TTM_ME function. Here, X is a sparse tensor  
%  (sptensor), U is a cell array of matrices of length ndims(X),
%  EDIMS specifies the dimensions that are to be handled elementwise, sdims
%  specifies those dimensions that are to be handled in the standard way,
%  and TFLAG indicates to multiply the matrix transpose.
%
%   See also TENSOR_TOOLBOX, TUCKER_ME, TTM_ME.
%
%   Code by Tamara Kolda and Jimeng Sun, 2008. 
%
%   Based on the paper:
%   T. G. Kolda and J. Sun. Scalable Tensor Decompositions for Multi-aspect
%   Data Mining. In: ICDM 2008: Proceedings of the 8th IEEE International
%   Conference on Data Mining, December 2008.  

% $Id: ttm_me_mem.m,v 1.2 2009/07/08 00:03:52 tgkolda Exp $

%% Setup and error checking

% Check number of input arguments
if (nargin < 4)
    error('TTM_ME requires four arguments');
end