Packs the list of tensors according to the structure. In the event that `elements` should be a scalar, `struct_template` must contain exactly one non-trivial element (for instance, `[[], {'x':elt}]`). Args: elements: Elements to be packed. A list of tensor, or a single tensor. struct
(elements, struct_template)
| 137 | |
| 138 | |
| 139 | def _Pack(elements, struct_template): |
| 140 | """Packs the list of tensors according to the structure. |
| 141 | |
| 142 | In the event that `elements` should be a scalar, `struct_template` must |
| 143 | contain exactly one non-trivial element (for instance, `[[], {'x':elt}]`). |
| 144 | |
| 145 | Args: |
| 146 | elements: Elements to be packed. A list of tensor, or a single tensor. |
| 147 | struct_template: The container structure in which to pack them. |
| 148 | Returns: |
| 149 | A python structure of the same type as `struct_template`, containing |
| 150 | `elements` as its contained elements. |
| 151 | """ |
| 152 | if not nest.is_sequence(elements): |
| 153 | return nest.pack_sequence_as(struct_template, [elements]) |
| 154 | return nest.pack_sequence_as(struct_template, elements) |
| 155 | |
| 156 | |
| 157 | def _EmptyAcc(slen, struct_template): |
no outgoing calls
no test coverage detected