class_docstr: Collects metrics and sends them directly to metrics service.
class_docstr_tok: ["Collects","metrics","and","sends","them","directly","to","metrics","service","."]
docstr: Pops off all metrics in the buffer and starts sending them to metrics service.
docstr_tok: ["Pops","off","all","metrics","in","the","buffer","and","starts","sending","them","to","metrics","service","."]
code: def _drain(self, close=False):
      """Pops off all metrics in the buffer and starts sending them to metrics service."""
  
      if not self._buffer:
          return
  
      if len(self._buffer) < BATCH_SIZE and not close:
          return
  
      # pop all the available metrics
      available_metrics, self._buffer = self._buffer, []
  
      self._send_metrics(available_metrics)
  
imports: from __future__ import absolute_import
  import datetime
  import logging
  import os
  import time
  import threading
  import queue
  import dateutil.tz
  from sagemaker.session import Session
label_desc: Use image node_id 3 for calling the _SyncMetricsSink obj's underlying member method code with example usage: obj._drain(close) without return types