class_docstr: An object use to hold the sharding policy for a Tensor.
class_docstr_tok: ["An","object","use","to","hold","the","sharding","policy","for","a","Tensor","."]
docstr: Sets the number of partitions for the current policy.
  
  If the policy has been frozen then shard_dimension must match the
  existing setting.
  
  Args:
    number_of_partitions: The number of partitions to use in the policy.
  
  Raises:
    ValueError: If the policy has been frozen and shard_dimension
      differs from the frozen value.
docstr_tok: ["Sets","the","number","of","partitions","for","the","current","policy",".","If","the","policy","has","been","frozen","then","shard_dimension","must","match","the","existing","setting",".","Args",":","number_of_partitions",":","The","number","of","partitions","to","use","in","the","policy",".","Raises",":","ValueError",":","If","the","policy","has","been","frozen","and","shard_dimension","differs","from","the","frozen","value","."]
code: def set_number_of_partitions(self, number_of_partitions):
      """Sets the number of partitions for the current policy.
  
      If the policy has been frozen then shard_dimension must match the
      existing setting.
  
      Args:
        number_of_partitions: The number of partitions to use in the policy.
  
      Raises:
        ValueError: If the policy has been frozen and shard_dimension
          differs from the frozen value.
      """
      if self._frozen:
          if self._number_of_partitions != number_of_partitions:
              raise ValueError(
                  f"Can't set number_of_partitions to {number_of_partitions} since "
                  f"it has been frozen to use {self._number_of_partitions}."
              )
      else:
          self._number_of_partitions = number_of_partitions
  
file_path: tensorflow-upstream/tensorflow/python/tpu/tpu_sharding.py
imports: from tensorflow.python.framework import tensor_shape
label_desc: Use image node_id 8 for calling the ShardingPolicy obj's underlying member method code with example usage: obj.set_number_of_partitions(number_of_partitions) without return types