code: def collect_requirements(
      self,
      state=INITIAL_STATE,
      current_node: Node = None,
      allocations: Dict[int, Optional[AllocationQuery]] = None,
      code: Dict[int, Optional[Callable]] = None,
      source_field: str = None,
  ):
      if allocations is None:
          allocations: Dict[int, Optional[AllocationQuery]] = {
              "shared": {},
              "operation": {},
          }
      if code is None:
          code: Dict[int, Optional[Callable]] = {
              "shared": {},
              "operation": {},
          }
      next_state = state
      if current_node is None:
          next_nodes = self.root_nodes.keys()
      else:
          if not isinstance(current_node, RefNode):
              if isinstance(current_node, TransformNode):
                  operation = current_node.operation
              else:
                  operation = current_node.decoder
  
              if isinstance(current_node, DecoderNode):
                  source_field = current_node.field_name
  
              fix = self.fieldname_to_fix[source_field]
              metadata = self.metadata[f"f{fix}"]
  
              operation.accept_field(self.handlers[source_field])
              operation.accept_globals(metadata, self.memory_read)
  
              (
                  next_state,
                  allocation,
              ) = operation.declare_state_and_memory(state)
              state_allocation = operation.declare_shared_memory(state)
  
              if next_state.device.type != "cuda" and isinstance(
                  operation, ModuleWrapper
              ):
                  msg = (
                      "Using a pytorch transform on the CPU is extremely"
                      "detrimental to the performance, consider moving the augmentation"
                      "on the GPU or using an FFCV native transform"
                  )
                  warnings.warn(msg, ResourceWarning)
  
              if isinstance(current_node, TransformNode):
                  current_node.jitted = next_state.jit_mode
  
              allocations["operation"][current_node.id] = allocation
              allocations["shared"][current_node.id] = state_allocation
              code["operation"][
                  current_node.id
              ] = operation.generate_code()
              code["shared"][
                  current_node.id
              ] = operation.generate_code_for_shared_state()
  
          next_nodes = self.adjacency_list[current_node]
  
      for node in next_nodes:
          self.collect_requirements(
              next_state,
              node,
              allocations,
              code,
              source_field=source_field,
          )
  
      return allocations, code
  
imports: from distutils.log import warn
  import warnings
  import ast
  from collections import defaultdict
  from typing import Callable, Dict, List, Optional, Sequence, Set
  from abc import ABC, abstractmethod
  from ffcv.pipeline.allocation_query import AllocationQuery
  from ffcv.pipeline.pipeline_spec import PipelineSpec
  from ffcv.pipeline.compiler import Compiler
  from ffcv.pipeline.allocation_query import allocate_query
  from .operation import Operation
  from ..transforms import ModuleWrapper
  from .state import State
  import torch
  import numpy
label_desc: Use image node_id 2 for calling the Graph obj's underlying member method code with example usage: obj.collect_requirements(state, current_node, allocations, code, source_field) and returns: allocations,  code