code: def test_stream_closing(
      self, log_session_streams, dataset_mock, config
  ):
      def make_msg_and_close(head):
          unclosed_streams = []
          for stream in list(StreamWrapper.session_streams.keys()):
              unclosed_streams.append(repr(stream.file_obj))
              stream.close()
          unclosed_streams = "\n".join(unclosed_streams)
          return f"{head}\n\n{unclosed_streams}"
  
      if StreamWrapper.session_streams:
          raise pytest.UsageError(
              make_msg_and_close(
                  "A previous test did not close the following streams:"
              )
          )
  
      dataset, _ = dataset_mock.load(config)
  
      consume(iter(dataset))
  
      if StreamWrapper.session_streams:
          raise AssertionError(
              make_msg_and_close(
                  "The following streams were not closed after a full iteration:"
              )
          )
  
imports: import io
  import pickle
  from collections import deque
  from pathlib import Path
  import pytest
  import torch
  import torchvision.transforms.v2
  from builtin_dataset_mocks import DATASET_MOCKS, parametrize_dataset_mocks
  from torch.testing._comparison import not_close_error_metas, ObjectPair, TensorLikePair
  from torch.utils.data import DataLoader
  from torch.utils.data.graph_settings import get_all_graph_pipes
  from torchdata.dataloader2.graph.utils import traverse_dps
  from torchdata.datapipes.iter import ShardingFilter, Shuffler
  from torchdata.datapipes.utils import StreamWrapper
  from torchvision import tv_tensors
  from torchvision._utils import sequence_to_str
  from torchvision.prototype import datasets
  from torchvision.prototype.datasets.utils import EncodedImage
  from torchvision.prototype.datasets.utils._internal import INFINITE_BUFFER_SIZE
  from torchvision.prototype.tv_tensors import Label
  from torchvision.transforms.v2._utils import is_pure_tensor
label_desc: Use image node_id 6 for calling the TestCommon obj's underlying member method code with example usage: obj.test_stream_closing(log_session_streams, dataset_mock, config) and returns: head, str, unclosed_streams