<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def load_data(self, data, datatype="ttl", namespace=None, graph=None, is_file=False, **kwargs):
 """ Loads data via file stream from python to triplestore Args: ----- data: The data or filepath to load datatype(['ttl', 'xml', 'rdf']):
 the type of data to load namespace: the namespace to use graph: the graph to load the data to. is_file(False):
 If true python will read the data argument as a filepath, determine the datatype from the file extension, read the file and send it to blazegraph as a datastream """

        log.setLevel(kwargs.get("log_level", self.log_level))
        time_start = datetime.datetime.now()
        datatype_map = {
            'ttl': 'text/turtle',
            'xml': 'application/rdf+xml',
            'rdf': 'application/rdf+xml',
            'nt': 'text/plain'
        }
        if is_file:
            datatype = data.split(os.path.extsep)[-1]
            file_name = data
            log.debug('starting data load of %s', file_name)
            data = open(data, 'rb').read()
        else:
            try:
                data = data.encode('utf-8')
            except AttributeError:
                # data already encoded
                pass
        try:
            content_type = datatype_map[datatype]
        except KeyError:
            raise NotImplementedError("'%s' is not an implemented data format",
                                      datatype)
        context_uri = pick(graph, self.graph)
        result = requests.post(url=self._make_url(namespace),
                               headers={"Content-Type": content_type},
                               params={"context-uri": context_uri},
                               data=data)
        if result.status_code == 200:
            if is_file:
                log.info (" loaded %s into blazegraph - %s",
                          file_name,
                          self.format_response(result.text))
            else:
                log.info(" loaded data - %s", self.format_response(result.text))
            log.setLevel(self.log_level)
            return result
        else:
            raise SyntaxError(result.text)