code: def _construct_inp_pos_to_param_buffer_name(
      new_gm, graph_signature, state_dict, tensor_constants=None
  ):
      # TODO Fix the period in params/buffers names later
      # maybe a pass to replace graph signature with fixed names
      param_buffer_name_to_corrected_name = {}
      constant_name_to_corrected_name = {}
  
      for name, value in state_dict.items():
          if name in graph_signature.buffers:
              if "." in name:
                  new_gm.register_buffer(name.replace(".", "_"), value)
                  param_buffer_name_to_corrected_name[
                      name
                  ] = name.replace(".", "_")
              else:
                  new_gm.register_buffer(name, value)
          if name in graph_signature.parameters:
              if "." in name:
                  new_gm.register_parameter(
                      name.replace(".", "_"), value
                  )
                  param_buffer_name_to_corrected_name[
                      name
                  ] = name.replace(".", "_")
              else:
                  new_gm.register_parameter(name, value)
  
      if tensor_constants is not None and len(tensor_constants) > 0:
          assert hasattr(graph_signature, "lifted_tensor_constants")
          for name, value in tensor_constants.items():
              if name in graph_signature.lifted_tensor_constants:
                  if isinstance(value, torch.Tensor):
                      new_gm.register_buffer(
                          name.replace(".", "_"), value
                      )
                  else:
                      setattr(new_gm, name.replace(".", "_"), value)
                  constant_name_to_corrected_name[name] = name.replace(
                      ".", "_"
                  )
  
      count = 0
      inp_pos_to_param_buffer_name = {}
      for node in new_gm.graph.nodes:
          if node.op == "placeholder":
              if node.name in graph_signature.inputs_to_buffers:
                  buffer_name = graph_signature.inputs_to_buffers[
                      node.name
                  ]
                  if buffer_name in param_buffer_name_to_corrected_name:
                      inp_pos_to_param_buffer_name[
                          count
                      ] = param_buffer_name_to_corrected_name[
                          buffer_name
                      ]
                  else:
                      inp_pos_to_param_buffer_name[count] = buffer_name
              if node.name in graph_signature.inputs_to_parameters:
                  param_name = graph_signature.inputs_to_parameters[
                      node.name
                  ]
                  if param_name in param_buffer_name_to_corrected_name:
                      inp_pos_to_param_buffer_name[
                          count
                      ] = param_buffer_name_to_corrected_name[
                          param_name
                      ]
                  else:
                      inp_pos_to_param_buffer_name[count] = param_name
              if hasattr(
                  graph_signature, "inputs_to_lifted_tensor_constants"
              ):
                  if (
                      node.name
                      in graph_signature.inputs_to_lifted_tensor_constants
                  ):
                      constant_name = graph_signature.inputs_to_lifted_tensor_constants[
                          node.name
                      ]
                      if (
                          constant_name
                          in constant_name_to_corrected_name
                      ):
                          inp_pos_to_param_buffer_name[
                              count
                          ] = constant_name_to_corrected_name[
                              constant_name
                          ]
                      else:
                          inp_pos_to_param_buffer_name[
                              count
                          ] = constant_name
              count += 1
  
      return inp_pos_to_param_buffer_name
  
file_path: pytorch/torch/export/_unlift.py
imports: import copy
  import torch
  import torch.utils._pytree
  from torch._export.utils import _check_input_constraints_pre_hook
  from torch.fx.graph import _PyTreeCodeGen, _PyTreeInfo
  from .exported_program import ExportedProgram
label_desc: Use image node_id 2 for calling a global function with example usage: _construct_inp_pos_to_param_buffer_name(new_gm, graph_signature, state_dict, tensor_constants) and returns: inp_pos_to_param_buffer_name