[docs]defrun(run_dir,file_in,file_out,input_path,static_path,secondary_factor,uniform_factor):""" Execute the main Post Loss Amplification workflow. Args: run_dir (str): the directory of where the process is running file_in (str): file name of input stream file_out (str): file name of output streak input_path (str): path to amplifications.bin static_path (str): path to lossfactors.bin secondary_factor (float): secondary factor to apply to post loss amplification uniform_factor (float): uniform factor to apply across all losses Returns: 0 (int): if no errors occurred """input_path=os.path.join(run_dir,input_path)model_storage=get_storage_from_config_path(os.path.join(run_dir,'model_storage.json'),os.path.join(run_dir,static_path),)items_amps=get_items_amplifications(input_path)plafactors=get_post_loss_amplification_factors(model_storage,secondary_factor,uniform_factor)# Set default factor should post loss amplification factor be missingdefault_factor=1.0ifuniform_factor==0.0elseuniform_factorwithExitStack()asstack:streams_in=get_streams_in(file_in,stack)iffile_outisNone:stream_out=sys.stdout.bufferelse:stream_out=stack.enter_context(open(file_out,'wb'))read_and_write_streams(streams_in,stream_out,items_amps,plafactors,default_factor)return0