class_docstr: A BlockList that submits tasks lazily on-demand.
  
  This BlockList is used for implementing read operations (e.g., to avoid
  needing to read all files of a Dataset when the user is just wanting to
  .take() the first few rows or view the schema).
class_docstr_tok: ["A","BlockList","that","submits","tasks","lazily","on-demand",".","This","BlockList","is","used","for","implementing","read","operations","(","e.g.",",","to","avoid","needing","to","read","all","files","of","a","Dataset","when","the","user","is","just","wanting","to",".take","(",")","the","first","few","rows","or","view","the","schema",")","."]
docstr: Iterate over the blocks along with their metadata.
  
  Note that, if block_for_metadata is False (default), this iterator returns
  pre-read metadata from the ReadTasks given to this LazyBlockList so it doesn't
  have to block on the execution of the read tasks. Therefore, the metadata may be
  under-specified, e.g. missing schema or the number of rows. If fully-specified
  block metadata is required, pass block_for_metadata=True. When dynamic block
  splitting is enabled, always block on the execution of the read tasks.
  
  The length of this iterator is not known until execution.
  
  Args:
      block_for_metadata: Whether we should block on the execution of read tasks
          in order to obtain fully-specified block metadata.
  
  Returns:
      An iterator of block references and the corresponding block metadata.
code: def iter_blocks_with_metadata(
      self,
      block_for_metadata: bool = False,
  ) -> Iterator[Tuple[ObjectRef[Block], BlockMetadata]]:
      """Iterate over the blocks along with their metadata.
  
      Note that, if block_for_metadata is False (default), this iterator returns
      pre-read metadata from the ReadTasks given to this LazyBlockList so it doesn't
      have to block on the execution of the read tasks. Therefore, the metadata may be
      under-specified, e.g. missing schema or the number of rows. If fully-specified
      block metadata is required, pass block_for_metadata=True. When dynamic block
      splitting is enabled, always block on the execution of the read tasks.
  
      The length of this iterator is not known until execution.
  
      Args:
          block_for_metadata: Whether we should block on the execution of read tasks
              in order to obtain fully-specified block metadata.
  
      Returns:
          An iterator of block references and the corresponding block metadata.
      """
      outer = self
  
      class Iter:
          def __init__(self):
              self._base_iter = outer._iter_block_partition_refs()
              self._pos = -1
              self._buffer = []
  
          def __iter__(self):
              return self
  
          def __next__(self):
              while not self._buffer:
                  self._pos += 1
                  generator_ref, _ = next(self._base_iter)
                  generator = ray.get(generator_ref)
                  refs = list(generator)
                  # This blocks until the read task completes, returning
                  # fully-specified block metadata for each output block.
                  metadata = ray.get(refs.pop(-1))
                  assert len(metadata) == len(refs)
                  for block_ref, meta in zip(refs, metadata):
                      self._buffer.append((block_ref, meta))
              return self._buffer.pop(0)
  
      return Iter()
  
imports: import math
  import uuid
  from typing import Any, Dict, Iterable, Iterator, List, Optional, Tuple, Union
  import ray
  from ray.data._internal.block_list import BlockList
  from ray.data._internal.memory_tracing import trace_allocation
  from ray.data._internal.progress_bar import ProgressBar
  from ray.data._internal.remote_fn import cached_remote_fn
  from ray.data._internal.stats import DatasetStats, _get_or_create_stats_actor
  from ray.data._internal.util import _split_list
  from ray.data.block import Block, BlockAccessor, BlockExecStats, BlockMetadata, BlockPartitionMetadata, MaybeBlockPartition
  from ray.data.context import DataContext
  from ray.data.datasource import ReadTask
  from ray.types import ObjectRef
label_desc: Use image node_id 20 for calling the LazyBlockList obj's underlying member method code with example usage: obj.iter_blocks_with_metadata(block_for_metadata) and returns: Iter, self, self