class_docstr: Represents the shape of a `Tensor`.
  
  A `TensorShape` represents a possibly-partial shape specification for a
  `Tensor`. It may be one of the following:
  
  * *Fully-known shape:* has a known number of dimensions and a known size
    for each dimension. e.g. `TensorShape([16, 256])`
  * *Partially-known shape:* has a known number of dimensions, and an unknown
    size for one or more dimension. e.g. `TensorShape([None, 256])`
  * *Unknown shape:* has an unknown number of dimensions, and an unknown
    size in all dimensions. e.g. `TensorShape(None)`
  
  If a tensor is produced by an operation of type `"Foo"`, its shape
  may be inferred if there is a registered shape function for
  `"Foo"`. See @{$adding_an_op#shape-functions-in-c$`Shape functions in C++`}
  for details of shape functions and how to register them. Alternatively,
  the shape may be set explicitly using @{tf.Tensor.set_shape}.
class_docstr_tok: ["Represents","the","shape","of","a","`","Tensor","`",".","A","`","TensorShape","`","represents","a","possibly-partial","shape","specification","for","a","`","Tensor","`",".","It","may","be","one","of","the","following",":","*","*","Fully-known","shape",":","*","has","a","known","number","of","dimensions","and","a","known","size","for","each","dimension",".","e.g",".","`","TensorShape","(","[","16",",","256","]",")","`","*","*","Partially-known","shape",":","*","has","a","known","number","of","dimensions",",","and","an","unknown","size","for","one","or","more","dimension",".","e.g",".","`","TensorShape","(","[","None",",","256","]",")","`","*","*","Unknown","shape",":","*","has","an","unknown","number","of","dimensions",",","and","an","unknown","size","in","all","dimensions",".","e.g",".","`","TensorShape","(","None",")","`","If","a","tensor","is","produced","by","an","operation","of","type","`","``","Foo","''","`",",","its","shape","may","be","inferred","if","there","is","a","registered","shape","function","for","`","``","Foo","''","`",".","See","@","{","$","adding_an_op","#","shape-functions-in-c","$","`","Shape","functions","in","C++","`","}","for","details","of","shape","functions","and","how","to","register","them",".","Alternatively",",","the","shape","may","be","set","explicitly","using","@","{","tf.Tensor.set_shape","}","."]
docstr: Returns the value of a dimension or a shape, depending on the key.
  
  Args:
    key: If `key` is an integer, returns the dimension at that index;
      otherwise if `key` is a slice, returns a TensorShape whose
      dimensions are those selected by the slice from `self`.
  
  Returns:
    A dimension if `key` is an integer, or a `TensorShape` if `key` is a
    slice.
  
  Raises:
    ValueError: If `key` is a slice, and any of its elements are negative, or
      if `self` is completely unknown and the step is set.
docstr_tok: ["Returns","the","value","of","a","dimension","or","a","shape",",","depending","on","the","key",".","Args",":","key",":","If","`","key","`","is","an","integer",",","returns","the","dimension","at","that","index",";","otherwise","if","`","key","`","is","a","slice",",","returns","a","TensorShape","whose","dimensions","are","those","selected","by","the","slice","from","`","self","`",".","Returns",":","A","dimension","if","`","key","`","is","an","integer",",","or","a","`","TensorShape","`","if","`","key","`","is","a","slice",".","Raises",":","ValueError",":","If","`","key","`","is","a","slice",",","and","any","of","its","elements","are","negative",",","or","if","`","self","`","is","completely","unknown","and","the","step","is","set","."]
code: def __getitem__(self, key):
      """Returns the value of a dimension or a shape, depending on the key.
  
      Args:
        key: If `key` is an integer, returns the dimension at that index;
          otherwise if `key` is a slice, returns a TensorShape whose
          dimensions are those selected by the slice from `self`.
  
      Returns:
        A dimension if `key` is an integer, or a `TensorShape` if `key` is a
        slice.
  
      Raises:
        ValueError: If `key` is a slice, and any of its elements are negative, or
          if `self` is completely unknown and the step is set.
      """
      if self._dims is not None:
          if isinstance(key, slice):
              return TensorShape(self._dims[key])
          else:
              return self._dims[key]
      else:
          if isinstance(key, slice):
              start = key.start if key.start is not None else 0
              stop = key.stop
  
              if key.step is not None:
                  # TODO(mrry): Handle these maybe.
                  raise ValueError("Steps are not yet handled")
              if stop is None:
                  # NOTE(mrry): This implies that TensorShape(None) is convertible with
                  # TensorShape(None)[1:], which is obviously not true. It would be
                  # possible to track the number of dimensions symbolically,
                  # and perhaps we should do that.
                  return unknown_shape()
              elif start < 0 or stop < 0:
                  # TODO(mrry): Handle this better, as it will be useful for handling
                  # suffixes of otherwise unknown shapes.
                  return unknown_shape()
              else:
                  return unknown_shape(ndims=stop - start)
          else:
              return Dimension(None)
  
imports: from .None import compat, dtypes
  from tensorboard.compat.proto import tensor_shape_pb2
label_desc: Use image node_id 10 for calling the TensorShape obj's underlying member method code with example usage: obj.__getitem__(key) and returns: TensorShape, self, Dimension, unknown_shape, unknown_shape, unknown_shape