code: def get_file_instructions(
      from_: int,
      to: int,
      filenames: Sequence[str],
      shard_lengths: Sequence[int],
  ) -> List[FileInstruction]:
      """Returns a list of files (+skip/take) to read [from_:to] items from shards.
  
      Args:
        from_: int, Index (included) of element from which to read.
        to: int, Index (excluded) of element to which to read.
        filenames: list of strings or ints, the filenames of the shards. Not really
          used, but to place in result.
        shard_lengths: the number of elements in every shard.
  
      Returns:
        list of dict(filename, skip, take).
      """
      index_start = 0  # Beginning (included) of moving window.
      index_end = 0  # End (excluded) of moving window.
      file_instructions = []
      for filename, length in zip(filenames, shard_lengths):
          if not length:
              continue  # Empty shard - can happen with temporary buckets.
          index_end += length
          if (
              from_ < index_end and to > index_start
          ):  # There is something to take.
              skip = from_ - index_start if from_ > index_start else 0
              take = to - index_start - skip if to < index_end else -1
              if take == 0:
                  continue
              file_instructions.append(
                  FileInstruction(
                      filename=filename,
                      skip=skip,
                      take=take,
                      examples_in_shard=length,
                  )
              )
          index_start += length
      return file_instructions
  
file_path: datasets/tensorflow_datasets/core/utils/shard_utils.py
imports: from __future__ import annotations
  import dataclasses
  import math
  import os
  from typing import Any, List, Optional, Sequence
label_desc: Use image node_id 2 for calling a global function with example usage: get_file_instructions(from_, to, filenames, shard_lengths) and returns: file_instructions