class_docstr: Generator of fake examples randomly and deterministically generated.
class_docstr_tok: ["Generator","of","fake","examples","randomly","and","deterministically","generated","."]
docstr: Generates a random tensor for a single feature.
docstr_tok: ["Generates","a","random","tensor","for","a","single","feature","."]
code: def _generate_random_obj(self, feature, tensor_info, rng):
      """Generates a random tensor for a single feature."""
      # TODO(tfds): Could improve the fake generatiion:
      # * Use the feature statistics (min, max)
      # * For Sequence features
      # * For Text
  
      # First we deal with the case of sub-datasets:
      if isinstance(feature, features_lib.Dataset):
          # For sub-datasets self._num_sub_examples examples are generated.
          generator = RandomFakeGenerator(
              feature.feature,
              num_examples=self._num_sub_examples,
              num_sub_examples=1,
              max_value=self._max_value,
          )
          # Returns the list of examples in the nested dataset.
          return list(generator)
  
      if self._constant_dynamic_shape:
          shape = [10 if s is None else s for s in tensor_info.shape]
      else:
          shape = [  # Fill dynamic shape with random values
              rng.integers(low=5, high=50) if s is None else s
              for s in tensor_info.shape
          ]
      if isinstance(feature, features_lib.ClassLabel):
          max_value = feature.num_classes
      elif (
          isinstance(feature, features_lib.Text) and feature.vocab_size
      ):
          max_value = feature.vocab_size
      elif self._max_value:
          max_value = self._max_value
      else:
          max_value = 255
  
      # We cast the data to make sure `encode_example` don't raise errors
      dtype = tensor_info.np_dtype
      # Generate some random values, depending on the dtype
      if dtype_utils.is_integer(dtype):
          return rng.integers(0, max_value, size=shape).astype(dtype)
      elif dtype_utils.is_floating(dtype):
          return rng.random(size=shape).astype(dtype)
      elif dtype_utils.is_bool(dtype):
          return (rng.random(size=shape) < 0.5).astype(dtype)
      elif dtype_utils.is_string(dtype):
          return self._generate_random_string_array(shape, rng)
      raise ValueError(
          "Fake generation not supported for {}".format(dtype)
      )
  
imports: from __future__ import annotations
  from collections.abc import Sequence
  import contextlib
  import enum
  import functools
  import os
  from typing import Any, Callable, Iterator, Optional
  from unittest import mock
  from absl import logging
  from etils import epath
  import numpy
  from tensorflow_datasets.core import dataset_builder
  from tensorflow_datasets.core import decode
  from tensorflow_datasets.core import features
  from tensorflow_datasets.core import file_adapters
  from tensorflow_datasets.core import read_only_builder
  from tensorflow_datasets.core import reader
  from tensorflow_datasets.core import splits
  from tensorflow_datasets.core.data_sources import array_record
  from tensorflow_datasets.core.utils import dtype_utils
  from tensorflow_datasets.core.utils import tree_utils
  from tensorflow_datasets.core.utils.lazy_imports_utils import tensorflow
  from tensorflow_datasets.testing import test_utils
label_desc: Use image node_id 3 for calling the RandomFakeGenerator obj's underlying member method code with example usage: obj._generate_random_obj(feature, tensor_info, rng) and returns: list, rng, rng, unknown, self