docstr: Evaluate the runtime and peak memory when the forward execution reaches the current region.
docstr_tok: ["Evaluate","the","runtime","and","peak","memory","when","the","forward","execution","reaches","the","current","region","."]
code: def _eval_fwd_mem_per_region(self, region: Region):
      """
      Evaluate the runtime and peak memory when the forward execution reaches the current region.
      """
  
      # upload parameters of the current region
      if region.r_id <= 0:
          self.runtime_mem += region.param_size
          self.fwd_reg_flow[region.r_id, region.r_id] = True
      else:
          self.fwd_reg_flow[region.r_id] = self.fwd_reg_flow[
              region.r_id - 1
          ]
          self.fwd_reg_flow[
              region.r_id, self.reg_buffer_to_free
          ] = False
          self.reg_buffer_to_free.clear()
  
      # prefetch parameters of the next region
      fwd_prefetch_region = region.fwd_prefetch_region
      if fwd_prefetch_region and requires_upload_p_in_fwd(
          self.region_list[fwd_prefetch_region.shared_rid]
      ):
          self.runtime_mem += fwd_prefetch_region.param_size
          self.fwd_reg_flow[
              region.r_id, fwd_prefetch_region.r_id
          ] = True
  
      for node in region.nodes:
          self.runtime_mem += calculate_fwd_tmp(
              node
          ) + calculate_fwd_out(node)
          self.peak_mem = max(self.runtime_mem, self.peak_mem)
  
          self.total_mem_saving += (
              node.node_info.runtime_fwd_mem - self.runtime_mem
          )
          self.fwd_node_mem[node] = self.runtime_mem
  
      if region.need_offload:
          self.runtime_mem -= region.param_size
  
          assert (
              len(self.reg_buffer_to_free) <= 1
          ), f"{len(self.reg_buffer_to_free)}"
          self.reg_buffer_to_free.append(region.r_id)
  
imports: import bisect
  from abc import ABC, abstractmethod
  from collections import OrderedDict
  from typing import Dict, List
  from torch.fx.node import Node
  from .region import Region
  from .util import *
label_desc: Use image node_id 7 for calling the AsynTrainingSimulator obj's underlying member method code with example usage: obj._eval_fwd_mem_per_region(region) without return types