code: def __assign_actual_buf_to_variable(
      info, actual_buf_sizes, buf_var_refs
  ):
      # create a dictionary to store assignment of actual buffers to Variables
  
      # vidx_to_abidx is short for variable index to actual buffer index
      vidx_to_abidx = {}
  
      # actual_assigned_flags is to remember if actual buffers are assigned or not
      actual_buf_num = len(actual_buf_sizes)
      actual_assigned_flags = np.empty(actual_buf_num, dtype=bool)
  
      for func_idx, _ in enumerate(info._network.function):
          actual_assigned_flags[:] = False
          for ref_crsr in range(actual_buf_num):
              # minus buf_idx means the corresponding buffer is not needed
              buf_idx = buf_var_refs[func_idx][ref_crsr]
              if buf_idx < 0:
                  continue
  
              # restore assignment determined in the previous func_idx
              vidx = info._variable_buffer_index[buf_idx][0]
              if vidx in vidx_to_abidx:
                  abidx = vidx_to_abidx[vidx]
                  actual_assigned_flags[abidx] = True
              else:
                  pass  # determine assignment for this vidx in the following for loop
  
          # determine new assignments of actual buffers to Variables
          for ref_crsr in range(actual_buf_num):
              # minus buf_idx means the corresponding buffer is not needed
              buf_idx = buf_var_refs[func_idx][ref_crsr]
              if buf_idx < 0:
                  continue
  
              # skip Variables to which an actual buffer is already assigned
              vidx = info._variable_buffer_index[buf_idx][0]
              if vidx in vidx_to_abidx:
                  continue
  
              # search for actual buffers vacant and large enough
              needed_size = info._variable_buffer_size[buf_idx]
              abidx = 0
              while abidx != actual_buf_num:
                  cond = not actual_assigned_flags[abidx]
                  cond &= needed_size <= actual_buf_sizes[abidx]
                  if cond:
                      actual_assigned_flags[abidx] = True
                      vidx_to_abidx[vidx] = abidx
                      break
                  else:
                      abidx += 1
  
              # increase size if buffers large enough was NOT found
              if abidx == actual_buf_num:
                  for abidx in range(actual_buf_num):
                      if not actual_assigned_flags[abidx]:
                          actual_buf_sizes[abidx] = needed_size
                          actual_assigned_flags[abidx] = True
                          vidx_to_abidx[vidx] = abidx
                          break
  
      return vidx_to_abidx
  
file_path: nnabla/python/src/nnabla/utils/converter/nnablart/save_variable_buffer.py
imports: import numpy
label_desc: Use image node_id 5 for calling a global function with example usage: __assign_actual_buf_to_variable(info, actual_buf_sizes, buf_var_refs) and returns: vidx_to_abidx