def unpack_grad_tuple(gv, gpt):
    'Unpack a previously packed collection of gradient tensors.\n\n  Args:\n    gv: A (grad, var) pair to be unpacked.\n    gpt: A GradPackTuple describing the packing operation that produced gv.\n\n  Returns:\n    A list of (grad, var) pairs corresponding to the values that were\n     originally packed into gv, maybe following subsequent operations like\n     reduction.\n  '
    elt_widths = [x.num_elements() for x in gpt.shapes]
    with ops.device(gv[0][0].device):
        with ops.name_scope('unpack'):
            splits = array_ops.split(gv[0], elt_widths)
            unpacked_gv = []
            for (idx, s) in enumerate(splits):
                unpacked_gv.append((array_ops.reshape(s, gpt.shapes[idx]), gpt.vars[idx]))
    return unpacked_gv
Unpack a previously packed collection of gradient tensors.

Args:
  gv: A (grad, var) pair to be unpacked.
  gpt: A GradPackTuple describing the packing operation that produced gv.

Returns:
  A list of (grad, var) pairs corresponding to the values that were
   originally packed into gv, maybe following subsequent operations like
   reduction.
def unpack_grad_tuple(gv, gpt):
    'Unpack a previously packed collection of gradient tensors.\n\n  Args:\n    gv: A (grad, var) pair to be unpacked.\n    gpt: A GradPackTuple describing the packing operation that produced gv.\n\n  Returns:\n    A list of (grad, var) pairs corresponding to the values that were\n     originally packed into gv, maybe following subsequent operations like\n     reduction.\n  '
    elt_widths = [x.num_elements() for x in gpt.shapes]
    with ops.device(gv[0][0].device):
        with ops.name_scope('unpack'):
            splits = array_ops.split(gv[0], elt_widths)
            unpacked_gv = []
            for (idx, s) in enumerate(splits):
                unpacked_gv.append((array_ops.reshape(s, gpt.shapes[idx]), gpt.vars[idx]))
    return unpacked_gv