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: gdetect_write.m
    path of file: ./repos/voc-dpm/gdetect
    
    the code of the file until where you have to start completion: function [bs, count] = gdetect_write(pyra, model, bs, trees, from_pos
    
function status = ex_write(model, ex, from_pos, is_belief, max_size)
% ------------------------------------------------------------------------
% write ex to fv cache
% ex  example to write

if from_pos
  loss      = ex.loss;
  is_mined  = 0;
  ex.key(2) = 0; % remove scale
  ex.key(3) = 0; % remove x position
  ex.key(4) = 0; % remove y position
else
  loss      = 1;
  is_mined  = 1;
end