parameters: (self, shape, shard_index=None)
return_statement: return tensor_shape.as_shape(dims)
docstring: Returns the shape of a shard of a full Tensor.
  
      When given the shape of a 'full-size' Tensor, returns the shape of
      the sub-Tensor after it has been sharded. Freezes the policy if it
      has not yet been frozen.
  
      Args:
        shape: The shape of the full-size Tensor to be sharded.
        shard_index: The index of the shard whose shape should be returned.
          shard_index can be None for sharding policies that use the same
          shape for every shard.
        freeze_config:
  
      Returns:
        The shape of the sharded version of the Tensor.
  
      Raises:
        ValueError: If shard_index is None when shards are of different
          shapes; or shard_index is not None and
          !(0<=shard_index<number_of_shards); or shape does not have at
          least self.shard_dimension+1 dimensions; or the value of
          shape's shard dimension is not a multiple of
          self.number_of_shards
docstring_summary: Returns the shape of a shard of a full Tensor.
docstring_tokens: Returns the shape of a shard of a full Tensor .
function: def get_sharded_shape(self, shape, shard_index=None):
      """Returns the shape of a shard of a full Tensor.
  
      When given the shape of a 'full-size' Tensor, returns the shape of
      the sub-Tensor after it has been sharded. Freezes the policy if it
      has not yet been frozen.
  
      Args:
        shape: The shape of the full-size Tensor to be sharded.
        shard_index: The index of the shard whose shape should be returned.
          shard_index can be None for sharding policies that use the same
          shape for every shard.
        freeze_config:
  
      Returns:
        The shape of the sharded version of the Tensor.
  
      Raises:
        ValueError: If shard_index is None when shards are of different
          shapes; or shard_index is not None and
          !(0<=shard_index<number_of_shards); or shape does not have at
          least self.shard_dimension+1 dimensions; or the value of
          shape's shard dimension is not a multiple of
          self.number_of_shards
      """
      if self._shard_dimension is None or self._number_of_shards is None:
        # Don't raise an error if the config is unset.
        return None
      if shard_index is not None:
        if shard_index < 0 or shard_index >= self.number_of_shards:
          raise ValueError("shard_index %d, but must be in [0,%d)." %
                           (shard_index, self._number_of_shards))
      shape = tensor_shape.as_shape(shape)
      if self._number_of_shards == 1:
        # Don't do anything when there's only one shard.
        return shape
      ndims = shape.ndims
      if ndims is None:
        raise ValueError("shape must be a specified shape not Unknown")
      if ndims <= self._shard_dimension:
        raise ValueError("shape %s does not contain shard_dimension %d" %
                         (shape.as_list(), self._shard_dimension))
      dims = shape.as_list()
      if dims[self._shard_dimension] is None:
        raise ValueError("shape %s must have a fixed size for dimension %d "
                         "that is known at graph construction time." %
                         (shape.as_list(), self._shard_dimension))
      if (dims[self._shard_dimension] % self._number_of_shards) != 0:
        raise ValueError("shape %s cannot be sharded %d ways along dimension %d" %
                         (shape.as_list(), self._number_of_shards,
                          self._shard_dimension))
      dims[self._shard_dimension] /= self._number_of_shards
      return tensor_shape.as_shape(dims)
function_tokens: def get_sharded_shape ( self , shape , shard_index = None ) : if self . _shard_dimension is None or self . _number_of_shards is None : # Don't raise an error if the config is unset. return None if shard_index is not None : if shard_index < 0 or shard_index >= self . number_of_shards : raise ValueError ( "shard_index %d, but must be in [0,%d)." % ( shard_index , self . _number_of_shards ) ) shape = tensor_shape . as_shape ( shape ) if self . _number_of_shards == 1 : # Don't do anything when there's only one shard. return shape ndims = shape . ndims if ndims is None : raise ValueError ( "shape must be a specified shape not Unknown" ) if ndims <= self . _shard_dimension : raise ValueError ( "shape %s does not contain shard_dimension %d" % ( shape . as_list ( ) , self . _shard_dimension ) ) dims = shape . as_list ( ) if dims [ self . _shard_dimension ] is None : raise ValueError ( "shape %s must have a fixed size for dimension %d " "that is known at graph construction time." % ( shape . as_list ( ) , self . _shard_dimension ) ) if ( dims [ self . _shard_dimension ] % self . _number_of_shards ) != 0 : raise ValueError ( "shape %s cannot be sharded %d ways along dimension %d" % ( shape . as_list ( ) , self . _number_of_shards , self . _shard_dimension ) ) dims [ self . _shard_dimension ] /= self . _number_of_shards return tensor_shape . as_shape ( dims )