# Copyright 2021 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Abstract data loader."""
import abc
from typing import Any, Mapping


class DataLoader(abc.ABC):
  """Base abstraction for data loaders."""

  @abc.abstractmethod
  def get_sample(self, index: int) -> Mapping[str, Any]:
    """Returns a mapping of input name to example."""
    pass

  def get_samples_count(self) -> int:
    """Returns total count of available samples."""
    return None

  def get_type_overwrites(self) -> Mapping[str, Any]:
    """Returns a mapping of features to tf.dtypes.DType.

    Used in gRPC when the default type inference is incorrect.
    """

    return {}
