code: def _build_fp32_params(cls, params, flatten=True):
      # create FP32 copy of parameters and grads
      if flatten:
          total_param_size = sum(p.data.numel() for p in params)
          fp32_params = torch.zeros(
              total_param_size,
              dtype=torch.float,
              device=params[0].device,
          )
          offset = 0
          for p in params:
              numel = p.data.numel()
              fp32_params[offset : offset + numel].copy_(
                  p.data.view(-1)
              )
              offset += numel
          fp32_params = torch.nn.Parameter(fp32_params)
          fp32_params.grad = fp32_params.data.new(total_param_size)
          return fp32_params
      else:
          fp32_params = []
          for p in params:
              p32 = torch.nn.Parameter(p.data.float())
              p32.grad = torch.zeros_like(p32.data)
              fp32_params.append(p32)
          return fp32_params
  
imports: import math
  from itertools import chain
  from typing import Optional
  import parlai.utils.logging
label_desc: Use image node_id 3 for calling the SafeFP16Optimizer obj's underlying member method code with example usage: obj._build_fp32_params(cls, params, flatten) and returns: fp32_params, fp32_params