"""Numpy stub for `tensor_spec`."""

__all__ = [
    'TensorSpec',
]


class DenseSpec(object):

  def __init__(self, shape, dtype, name=None):
    self.shape = shape
    self.dtype = dtype
    self.name = name

  def __repr__(self):
    return '{}(shape={}, dtype={}, name={})'.format(
        type(self).__name__, self.shape, repr(self.dtype), repr(self.name))


class TensorSpec(DenseSpec):
  pass

"""Numpy stub for `tensor_spec`."""

from tensorflow_probability.python.internal.backend.numpy.ops import _convert_to_tensor

__all__ = [
    'TensorSpec',
]


class DenseSpec(object):

  def __init__(self, shape, dtype, name=None):
    self.shape = shape
    self.dtype = dtype
    self.name = name

  def __repr__(self):
    return '{}(shape={}, dtype={}, name={})'.format(
        type(self).__name__, self.shape, repr(self.dtype), repr(self.name))


class TensorSpec(DenseSpec):

  @classmethod
  def from_tensor(cls, tensor, name=None):
    tensor = _convert_to_tensor(tensor)
    return cls(tensor.shape, tensor.dtype, name)

Add `from_tensor` classmethod to `TensorSpec` in the Numpy backend.
Add `from_tensor` classmethod to `TensorSpec` in the Numpy backend.

PiperOrigin-RevId: 466171774

  """Numpy stub for `tensor_spec`."""
+ 
+ from tensorflow_probability.python.internal.backend.numpy.ops import _convert_to_tensor
  
  __all__ = [
      'TensorSpec',
  ]
  
  
  class DenseSpec(object):
  
    def __init__(self, shape, dtype, name=None):
      self.shape = shape
      self.dtype = dtype
      self.name = name
  
    def __repr__(self):
      return '{}(shape={}, dtype={}, name={})'.format(
          type(self).__name__, self.shape, repr(self.dtype), repr(self.name))
  
  
  class TensorSpec(DenseSpec):
-   pass
  
+   @classmethod
+   def from_tensor(cls, tensor, name=None):
+     tensor = _convert_to_tensor(tensor)
+     return cls(tensor.shape, tensor.dtype, name)
+ 
Add `from_tensor` classmethod to `TensorSpec` in the Numpy backend.
## Code Before:
"""Numpy stub for `tensor_spec`."""

__all__ = [
    'TensorSpec',
]


class DenseSpec(object):

  def __init__(self, shape, dtype, name=None):
    self.shape = shape
    self.dtype = dtype
    self.name = name

  def __repr__(self):
    return '{}(shape={}, dtype={}, name={})'.format(
        type(self).__name__, self.shape, repr(self.dtype), repr(self.name))


class TensorSpec(DenseSpec):
  pass

## Instruction:
Add `from_tensor` classmethod to `TensorSpec` in the Numpy backend.
## Code After:
"""Numpy stub for `tensor_spec`."""

from tensorflow_probability.python.internal.backend.numpy.ops import _convert_to_tensor

__all__ = [
    'TensorSpec',
]


class DenseSpec(object):

  def __init__(self, shape, dtype, name=None):
    self.shape = shape
    self.dtype = dtype
    self.name = name

  def __repr__(self):
    return '{}(shape={}, dtype={}, name={})'.format(
        type(self).__name__, self.shape, repr(self.dtype), repr(self.name))


class TensorSpec(DenseSpec):

  @classmethod
  def from_tensor(cls, tensor, name=None):
    tensor = _convert_to_tensor(tensor)
    return cls(tensor.shape, tensor.dtype, name)
