class_docstr: An object used to monitor the progress of a :class:`MultipartEncoder`.
  
  The :class:`MultipartEncoder` should only be responsible for preparing and
  streaming the data. For anyone who wishes to monitor it, they shouldn't be
  using that instance to manage that as well. Using this class, they can
  monitor an encoder and register a callback. The callback receives the
  instance of the monitor.
  
  To use this monitor, you construct your :class:`MultipartEncoder` as you
  normally would.
  
  .. code-block:: py
  
      from requests_toolbelt import (MultipartEncoder,
                                     MultipartEncoderMonitor)
      import requests
  
      def callback(monitor):
          # Do something with this information
          pass
  
      m = MultipartEncoder(fields={'field0': 'value0'})
      monitor = MultipartEncoderMonitor(m, callback)
      headers = {'Content-Type': monitor.content_type}
      r = requests.post('https://httpbin.org/post', data=monitor,
                        headers=headers)
  
  Alternatively, if your use case is very simple, you can use the following
  pattern.
  
  .. code-block:: py
  
      from requests_toolbelt import MultipartEncoderMonitor
      import requests
  
      def callback(monitor):
          # Do something with this information
          pass
  
      monitor = MultipartEncoderMonitor.from_fields(
          fields={'field0': 'value0'}, callback
          )
      headers = {'Content-Type': montior.content_type}
      r = requests.post('https://httpbin.org/post', data=monitor,
                        headers=headers)
class_docstr_tok: ["An","object","used","to","monitor","the","progress","of","a",":","class",":","`","MultipartEncoder","`",".","The",":","class",":","`","MultipartEncoder","`","should","only","be","responsible","for","preparing","and","streaming","the","data",".","For","anyone","who","wishes","to","monitor","it",",","they","should","n't","be","using","that","instance","to","manage","that","as","well",".","Using","this","class",",","they","can","monitor","an","encoder","and","register","a","callback",".","The","callback","receives","the","instance","of","the","monitor",".","To","use","this","monitor",",","you","construct","your",":","class",":","`","MultipartEncoder","`","as","you","normally","would",".","..","code-block",":",":","py","from","requests_toolbelt","import","(","MultipartEncoder",",","MultipartEncoderMonitor",")","import","requests","def","callback","(","monitor",")",":","#","Do","something","with","this","information","pass","m","=","MultipartEncoder","(","fields=","{","'field0","'",":","'value0","'","}",")","monitor","=","MultipartEncoderMonitor","(","m",",","callback",")","headers","=","{","'Content-Type","'",":","monitor.content_type","}","r","=","requests.post","(","'https",":","\/\/httpbin.org\/post","'",",","data=monitor",",","headers=headers",")","Alternatively",",","if","your","use","case","is","very","simple",",","you","can","use","the","following","pattern",".","..","code-block",":",":","py","from","requests_toolbelt","import","MultipartEncoderMonitor","import","requests","def","callback","(","monitor",")",":","#","Do","something","with","this","information","pass","monitor","=","MultipartEncoderMonitor.from_fields","(","fields=","{","'field0","'",":","'value0","'","}",",","callback",")","headers","=","{","'Content-Type","'",":","montior.content_type","}","r","=","requests.post","(","'https",":","\/\/httpbin.org\/post","'",",","data=monitor",",","headers=headers",")"]
code: def from_fields(
      cls, fields, boundary=None, encoding="utf-8", callback=None
  ):
      encoder = MultipartEncoder(fields, boundary, encoding)
      return cls(encoder, callback)
  
imports: import contextlib
  import io
  import os
  from uuid import uuid4
  import requests
  from .._compat import fields
label_desc: Use image node_id 2 for calling the MultipartEncoderMonitor obj's underlying member method code with example usage: obj.from_fields(cls, fields, boundary, encoding, callback) and returns: cls