class_docstr: Concat gradients together to optimize transfer.
docstr: Returns:
      bool - False if grads cannot be packed due to various reasons.
docstr_tok: ["Returns",":","bool","-","False","if","grads","can","not","be","packed","due","to","various","reasons","."]
code: def compute_strategy(self, grads):
      """
      Returns:
          bool - False if grads cannot be packed due to various reasons.
      """
      for g in grads:
          if not g.shape.is_fully_defined():
              logger.warn(
                  "Found gradient with incomplete shape: "
                  "{} has shape {}".format(g.name, g.shape)
              )
              return False
  
      self._shapes = [g.shape for g in grads]
      self._sizes = [g.shape.num_elements() for g in grads]
      self._total_size = sum(self._sizes)
      if self._total_size / self._num_split < 1024:
          logger.info("Skip GradientPacker due to too few gradients.")
          return False
      # should have the same dtype
      dtypes = {g.dtype for g in grads}
      if len(dtypes) != 1:
          logger.info(
              "Skip GradientPacker due to inconsistent gradient types."
          )
          return False
      self._grad_dtype = grads[0].dtype
  
      split_size = self._total_size // self._num_split
      split_size_last = self._total_size - split_size * (
          self._num_split - 1
      )
      self._split_sizes = [split_size] * (self._num_split - 1) + [
          split_size_last
      ]
      logger.info(
          "Will pack {} gradients of total dimension={} into {} splits.".format(
              len(self._sizes), self._total_size, self._num_split
          )
      )
      return True
  
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 2 for calling the GradientPacker obj's underlying member method code with example usage: obj.compute_strategy(grads) and returns: True, False, False, False