// Create the Object Pool based on the PooledPredictionEnginePolicy.
        // This method is only used once, from the cosntructor.
        private ObjectPool <PredictionEngine <TData, TPrediction> > CreatePredictionEngineObjectPool()
        {
            var predEnginePolicy = new PooledPredictionEnginePolicy <TData, TPrediction>(_mlContext, _mlModel);

            DefaultObjectPool <PredictionEngine <TData, TPrediction> > pool;

            if (_maxObjectsRetained != -1)
            {
                pool = new DefaultObjectPool <PredictionEngine <TData, TPrediction> >(predEnginePolicy, _maxObjectsRetained);
            }
            else
            {
                //default maximumRetained is Environment.ProcessorCount * 2, if not explicitly provided
                pool = new DefaultObjectPool <PredictionEngine <TData, TPrediction> >(predEnginePolicy);
            }

            return(pool);
        }
        // Create the Object Pool based on the PooledPredictionEnginePolicy.
        // This method is only used once, from the cosntructor.
        private void CreatePredictionEngineObjectPools()
        {
            for (int i = 0; i != _mlModels.Count; i++)
            {
                var modelName = _mlModelNames[i];
                var model     = _mlModels[i];

                var modelPredEnginePolicy = new PooledPredictionEnginePolicy <TData, TPrediction>(_mlContext, model);

                DefaultObjectPool <PredictionEngine <TData, TPrediction> > poolForModel;
                if (_maxObjectsRetained != -1)
                {
                    poolForModel = new DefaultObjectPool <PredictionEngine <TData, TPrediction> >(modelPredEnginePolicy, _maxObjectsRetained);
                }
                else
                {
                    //default maximumRetained is Environment.ProcessorCount * 2, if not explicitly provided
                    poolForModel = new DefaultObjectPool <PredictionEngine <TData, TPrediction> >(modelPredEnginePolicy);
                }

                this._namedPools.Add(modelName, poolForModel);
            }
        }