class_docstr: This class provides the structure for defining neural networks in a compositional way.
  An `AbstractNeuralModel` accepts as input `TRawDatapoint`, a single example. Each model can have some
  metadata. For example, this may be the vocabulary of words to be represented and their mappings to integer ids.
  The computed metadata is then used to build a `TNeuralModule` (a `nn.Module`) which contains
  the definition of the neural network architecture and its parameters. During training and testing, each `TRawDatapoint`
  is converted to a tensorized format `TTensorizedDatapoint`. By batching multiple `TTensorizedDatapoint` a minibatch
  is created which is the input of the `TNeuralModule`.
  
  To create an `AbstractNeuralModel`:
  
  * Compute the metadata.
      * Initialize metadata in `initialize_metadata`. Store any metadata structures within the model.
      * Update this structure for each example in `update_metadata_from`. Explicitly unpack/transform any parts of the
          `TRawDatapoint` and invoke the `update_metadata_from` for all child models.
      * Finally, compute the model metadata in `finalize_metadata` and store them as fields in your implementation
          of the `AbstractNeuralModel`. Optionally, discard any temporary structures within the model.
  
  * Implement `build_neural_module()` that uses the metadata previously computed to create a `TNeuralModule`, ie.
      a concrete `nn.Module` or `ModuleWithMetrics`. Note that no elements of the neural network should be stored
      in this object but they should be returned.
  * Define `tensorize()` accepting a single `TRawDatapoint` and yielding a `TTensorizedDatapoint`.
      Each `TTensorizedDatapoint` should be considered a single sample for your neural network. Each model should
      call its child models (if any) to delegate tensorization of the relevant parts of the `TRawDatapoint`
  
  * Finally, to create minibatches:
      * Implement `initialize_minibatch` which creates a dictionary that will be populated with the information from
          multiple `TTensorizedDatapoint`s. Explicitly invoke child models to initialize aspect of the minibatch
          that are their responsibility.
      * Implement `extend_minibatch_with` to extend the minibatch with an additional sample. Return `True`
          if the minibatch can be further extended. Explicitly deconstruct the `TTensorizedDatapoint` and pass its
          parts to the responsible child models.
      * Implement `finalize_minibatch` to finalize the minibatch (invoking this for any child models). This
          should return a dictionary of PyTorch tensors ready to be consumed by the `forward()` of the `TNeuralModule`.
docstr: Add a datapoint to the partial minibatch. If for some reason the minibatch cannot accumulate
      additional samples after this one, this method should return False. Once the minibatch
      is full, `finalize_minibatch()` will be invoked.
  
  Note to implementors: Commonly, each model will unpack the `tensorized_datapoint` and invoke `extend_minibatch_with`
      of its child models. Then, if at least one of the child models returns False
      then this function should also return False.
  
  :param tensorized_datapoint: the datapoint to be added. This parameter is the output of `tensorize()`.
  :param partial_minibatch: the minibatch data to be populated. This is the dictionary that was initialized
      by `initialize_minibatch`.
  :return True if the minibatch can be further extended. False if for some reason the minibatch is full.
docstr_tok: ["Add","a","datapoint","to","the","partial","minibatch",".","If","for","some","reason","the","minibatch","can","not","accumulate","additional","samples","after","this","one",",","this","method","should","return","False",".","Once","the","minibatch","is","full",",","`","finalize_minibatch","(",")","`","will","be","invoked",".","Note","to","implementors",":","Commonly",",","each","model","will","unpack","the","`","tensorized_datapoint","`","and","invoke","`","extend_minibatch_with","`","of","its","child","models",".","Then",",","if","at","least","one","of","the","child","models","returns","False","then","this","function","should","also","return","False",".",":","param","tensorized_datapoint",":","the","datapoint","to","be","added",".","This","parameter","is","the","output","of","`","tensorize","(",")","`",".",":","param","partial_minibatch",":","the","minibatch","data","to","be","populated",".","This","is","the","dictionary","that","was","initialized","by","`","initialize_minibatch","`",".",":","return","True","if","the","minibatch","can","be","further","extended",".","False","if","for","some","reason","the","minibatch","is","full","."]
code: def extend_minibatch_with(
      self,
      tensorized_datapoint: TTensorizedDatapoint,
      partial_minibatch: Dict[str, Any],
  ) -> bool:
      """
      Add a datapoint to the partial minibatch. If for some reason the minibatch cannot accumulate
          additional samples after this one, this method should return False. Once the minibatch
          is full, `finalize_minibatch()` will be invoked.
  
      Note to implementors: Commonly, each model will unpack the `tensorized_datapoint` and invoke `extend_minibatch_with`
          of its child models. Then, if at least one of the child models returns False
          then this function should also return False.
  
      :param tensorized_datapoint: the datapoint to be added. This parameter is the output of `tensorize()`.
      :param partial_minibatch: the minibatch data to be populated. This is the dictionary that was initialized
          by `initialize_minibatch`.
      :return True if the minibatch can be further extended. False if for some reason the minibatch is full.
      """
      raise NotImplementedError()
  
imports: from typing_extensions import final
  import gzip
  import os
  import torch
  from abc import ABC, abstractmethod
  from concurrent import futures
  from dpu_utils.utils.iterators import BufferedIterator, ThreadedIterator, shuffled_iterator
  from itertools import islice
  from pathlib import Path
  from torch import nn
  from typing import Any, Dict, Generic, Iterable, Iterator, List, Mapping, NamedTuple, Optional, Tuple, Type, TypeVar, Union
label_desc: Use image node_id 15 for calling the AbstractNeuralModel obj's underlying member method code with example usage: obj.extend_minibatch_with(tensorized_datapoint, partial_minibatch) without return types