"""Defines the abstract interface for classes that reference values."""

import abc
from typing import Any

from tensorflow_federated.python.core.impl.types import typed_object


class ValueReference(typed_object.TypedObject, metaclass=abc.ABCMeta):
  """An abstract interface for classes that reference values.

  This interfaces provides the capability to maniplutate values without
  requiring them to be materialized as Python objects.
  """

  @abc.abstractmethod
  def get_value(self) -> Any:
    pass


import abc
from typing import Union

import numpy as np

from tensorflow_federated.python.core.impl.types import typed_object


class ServerArrayReference(typed_object.TypedObject, metaclass=abc.ABCMeta):
  """An abstract interface representing references to server placed values."""

  @abc.abstractmethod
  def get_value(self) -> Union[np.generic, np.ndarray]:
    """Returns the referenced value as a numpy scalar or array."""
    raise NotImplementedError

Update the Value Reference API to be more precise about the types of values being referenced.
Update the Value Reference API to be more precise about the types of values being referenced.

PiperOrigin-RevId: 404647934

- """Defines the abstract interface for classes that reference values."""
  
  import abc
- from typing import Any
+ from typing import Union
+ 
+ import numpy as np
  
  from tensorflow_federated.python.core.impl.types import typed_object
  
  
- class ValueReference(typed_object.TypedObject, metaclass=abc.ABCMeta):
+ class ServerArrayReference(typed_object.TypedObject, metaclass=abc.ABCMeta):
+   """An abstract interface representing references to server placed values."""
-   """An abstract interface for classes that reference values.
- 
-   This interfaces provides the capability to maniplutate values without
-   requiring them to be materialized as Python objects.
-   """
  
    @abc.abstractmethod
-   def get_value(self) -> Any:
-     pass
+   def get_value(self) -> Union[np.generic, np.ndarray]:
+     """Returns the referenced value as a numpy scalar or array."""
+     raise NotImplementedError
  
Update the Value Reference API to be more precise about the types of values being referenced.
## Code Before:
"""Defines the abstract interface for classes that reference values."""

import abc
from typing import Any

from tensorflow_federated.python.core.impl.types import typed_object


class ValueReference(typed_object.TypedObject, metaclass=abc.ABCMeta):
  """An abstract interface for classes that reference values.

  This interfaces provides the capability to maniplutate values without
  requiring them to be materialized as Python objects.
  """

  @abc.abstractmethod
  def get_value(self) -> Any:
    pass

## Instruction:
Update the Value Reference API to be more precise about the types of values being referenced.
## Code After:

import abc
from typing import Union

import numpy as np

from tensorflow_federated.python.core.impl.types import typed_object


class ServerArrayReference(typed_object.TypedObject, metaclass=abc.ABCMeta):
  """An abstract interface representing references to server placed values."""

  @abc.abstractmethod
  def get_value(self) -> Union[np.generic, np.ndarray]:
    """Returns the referenced value as a numpy scalar or array."""
    raise NotImplementedError
