Returns a `TensorShape` combining the information in `self` and `other`.

        The dimensions in `self` and `other` are merged elementwise,
        according to the rules defined for `Dimension.merge_with()`.

        Args:
          other: Another `TensorShape`.

        Returns:
          A `TensorShape` containing the combined information of `self` and
          `other`.

        Raises:
          ValueError: If `self` and `other` are not convertible.

def merge_with(self, other):
        """Returns a `TensorShape` combining the information in `self` and `other`.

        The dimensions in `self` and `other` are merged elementwise,
        according to the rules defined for `Dimension.merge_with()`.

        Args:
          other: Another `TensorShape`.

        Returns:
          A `TensorShape` containing the combined information of `self` and
          `other`.

        Raises:
          ValueError: If `self` and `other` are not convertible.
        """
        other = as_shape(other)
        if self._dims is None:
            return other
        else:
            try:
                self.assert_same_rank(other)
                new_dims = []
                for i, dim in enumerate(self._dims):
                    new_dims.append(dim.merge_with(other[i]))
                return TensorShape(new_dims)
            except ValueError:
                raise ValueError("Shapes %s and %s are not convertible" % (self, other))