class_docstr: Concat gradients together to optimize transfer.
docstr: Args:
      grads (list): list of gradient tensors
  
  Returns:
      packed list of gradient tensors to be aggregated.
docstr_tok: ["Args",":","grads","(","list",")",":","list","of","gradient","tensors","Returns",":","packed","list","of","gradient","tensors","to","be","aggregated","."]
code: def pack(self, grads):
      """
      Args:
          grads (list): list of gradient tensors
  
      Returns:
          packed list of gradient tensors to be aggregated.
      """
      for i, g in enumerate(grads):
          assert g.shape == self._shapes[i]
  
      with cached_name_scope("GradientPacker", top_level=False):
          concat_grads = tf.concat(
              [tf.reshape(g, [-1]) for g in grads],
              0,
              name="concatenated_grads",
          )
          # concat_grads = tf.cast(concat_grads, tf.float16)
          grad_packs = tf.split(concat_grads, self._split_sizes)
          return grad_packs
  
imports: import operator
  from contextlib import contextmanager
  import tensorflow
  import threading
  from ..compat import tfv1
  from ..tfutils.common import get_tf_version_tuple
  from ..tfutils.scope_utils import cached_name_scope, under_name_scope
  from ..tfutils.varreplace import custom_getter_scope
  from ..utils import logger
  from ..utils.argtools import call_only_once
label_desc: Use image node_id 3 for calling the GradientPacker obj's underlying member method code with example usage: obj.pack(grads) and returns: grad_packs